Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Desktop

This thread is locked; no one can reply to it. rss feed Print
Desktop
Simon Fischer
Member #7,567
July 2006

Is there a posibillity to draw direct onto the desktop?

LennyLen
Member #5,313
December 2004
avatar

Quote:

Is there a posibillity to draw direct onto the desktop?

Not using allegro alone.

Andrei Ellman
Member #3,434
April 2003

Have a look at the following Allegro projects:

Aggression
LexEyes

Also worth looking at is this thread. I think there may be other threads that could help out, but I can't find them right now.

Bear in mind that these methods are Windows only, and you'd have to code the means for drawing on other osses' desktops yourself.

AE.

--
Don't let the illegitimates turn you into carbon.

BAF
Member #2,981
December 2002
avatar

Aggression just takes a screenshot of the desktop though.

A J
Member #3,025
December 2002
avatar

Quote:

Is there a posibillity to draw direct onto the desktop?

you can draw to a bitmap, then blit that on the desktop using allegro
(at least in windows you can).

___________________________
The more you talk, the more AJ is right. - ML

GullRaDriel
Member #3,861
September 2003
avatar

Take a look Here.

Spellcaster explain how to read/write to the desktop, the code is from the link i gave.

1#include <allegro.h>
2#include <winalleg.h>
3 
4BITMAP* getBitmapFromClipboard() {
5 BITMAP *result = NULL;
6
7 if (!IsClipboardFormatAvailable(CF_BITMAP)) {
8 return NULL;
9 }
10
11 if (OpenClipboard(win_get_window())) {
12 HBITMAP hbmp;
13
14 hbmp = GetClipboardData(CF_BITMAP);
15 if (hbmp != NULL) {
16 result = convert_hbitmap_to_bitmap(hbmp);
17 }
18 CloseClipboard();
19 }
20 return result;
21}
22 
23void copyBitmapToClipboard(BITMAP *bmp) {
24 if (OpenClipboard(win_get_window())) {
25 if (EmptyClipboard()) {
26 HBITMAP hbmp = convert_bitmap_to_hbitmap(bmp);
27 if (hbmp) {
28 if (!SetClipboardData(CF_BITMAP, hbmp)) {
29 DeleteObject(hbmp);
30 }
31 CloseClipboard();
32 }
33 }
34 }
35}
36 
37 
38 
39int main(int argc, char** argv) {
40 BITMAP *bmp;
41
42 allegro_init();
43 set_color_depth(16);
44 set_gfx_mode(GFX_GDI, 400, 400, 0, 0);
45
46 install_keyboard();
47 install_timer();
48
49 bmp = getBitmapFromClipboard();
50 if (bmp) {
51 int a;
52 for (a=0; a < bmp->h; a+=2) {
53 hline(bmp, 0, a, bmp->w, 0);
54 }
55 copyBitmapToClipboard(bmp);
56 }
57
58 while (!key[KEY_ESC]) {
59 if (bmp) {
60 blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
61 }
62 rest(2);
63 }
64 destroy_bitmap(bmp);
65}
66END_OF_MAIN()

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Johan Halmén
Member #1,550
September 2001

It would be fun with a game using the desktop. Imagine that you have some important files (documents and applications) on the desktop. Then comes a tank trying to destroy them and you control Mario, who tries to smash the tank with a baseball bat, before it destroys your files.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

GullRaDriel
Member #3,861
September 2003
avatar

It is called a playing Virus ;-p

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

deps
Member #3,858
September 2003
avatar

Speaking of virus. I once had a 3D game called virus. The player was driving around "inside the computer" blowing up evil worms. The game loaded images it found in subdirectories and displayed them on the walls. If i remember it correctly it also created the map to look like your directory tree.

Edit: tried to find a link with screenshots. But found mostly pages about the Amiga game with the same name. And a lot more fun, imo.

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

HoHo
Member #4,534
April 2004
avatar

Quote:

Imagine that you have some important files (documents and applications) on the desktop. Then comes a tank trying to destroy them and you control Mario, who tries to smash the tank with a baseball bat, before it destroys your files.

Why settle with 2d when you can use 2.5D ;D
http://www.cs.unm.edu/~dlchao/flake/doom/
There are some quite good points about network administration there.

[edit]

http://psdoom.sourceforge.net/
Add networking support so multiple admins can work the machine at the same time and/or remotely administer a machine.

Now wouldn't that be a nice thing :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

axilmar
Member #1,204
April 2001

Quote:

Is there a posibillity to draw direct onto the desktop?

On Windows you can write to the desktop by obtaining the handle to it using the GetDesktopWindow() function, then the function GetDC() returns the device context of the desktop's client area.

On X-Windows you can apply a similar technique, if I recall.

Andrei Ellman
Member #3,434
April 2003

Johan Halmén said:

It would be fun with a game using the desktop. Imagine that you have some important files (documents and applications) on the desktop. Then comes a tank trying to destroy them and you control Mario, who tries to smash the tank with a baseball bat, before it destroys your files.

I recall a Windows screensaver that brought the desktop icons alive and had some creature trying to chase them, and if it caught an icon, it made a squeak and disappeared.

In order to do such a thing, a program could peek in the user's desktop folder and global desktop folder and get the icons from all shortcuts that it finds (not sure how to get the icons off non-shortcut entities such as "My Computer" etc.). I think that the positions of each icon on the desktop are stored somewhere inside the registry.

To make things even more interesting, if it was possible to find the area occupied by all windows and dialogs (I'm not sure if such a thing is possible - it might be disabled for security reasons, or maybe it is possible - who knows), the icons could be made to hide behind certain windows. If doing this, care would have to be taken with windows that use transparency-tricks to create irregular shapes with holes so that the icons hide behind the right parts of these windows. Of course, if you take translucent windows into account, things get even trickier.

AE.

--
Don't let the illegitimates turn you into carbon.

Jakub Wasilewski
Member #3,653
June 2003
avatar

Quote:

The game loaded images it found in subdirectories and displayed them on the walls
...
tried to find a link with screenshots. But found mostly...

That's because there was too much pr0n on the walls and nobody wanted to make his interest in transformer sex public ;).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Go to: