Drawing on the desktop background..

Started by
10 comments, last by zedzeek 17 years, 5 months ago
Hi,Are there any method or any source that draws the OpenGL on desktop background for windows?
Advertisement
One method involving a hook is described at Andreas Jönsson's site (http://www.angelcode.com).

EDIT: Of course, if you don't care about the icons being drawn on top, then you can have it a lot simpler by making your window transparent.
Yes,I tried the code it is running...but I need to use openGL commands to draw more complex things like meshes... How can I make transparant the OpenGL window or DirectX window?
One option (and I have no idea if this is the best or even decent) is to create an ActiveX control or other web-embeddable component and use ActiveDesktop. I've seen an animated desktop that used Flash (or maybe Shockwave) that basically was just a webpage with the content embedded.

That may or may not be easier than what AngelCode suggests...
Rendering to the desktop window with OpenGL is a doomed idea.
The window doesn't belong to your process and for OpenGL you'd need to select a pixelformat. This only works once in the lifetime of a window, and you would have to destroy the desktop window to get rid of it, but you can't because it's not yours.
I guess Vista will be even less cooperative in that matter.
One thing that i have implemented in an openGL rubix-cube program, was a mode that cuts away the window around the model. It does this via a glReadPixels and then uses that data to fill a "window region" object (look it up in the MSDN).

This works with a few caveats:

the glReadPixels call is usually slow by its functionality. however i found that ATI cards are at a extreme advantage over NVidia cards on this; My Radeon 9600XT would peform this call without a performance hit, unlike every GeForce card ive tried.

Also, by keeping your window as small as possible, and reading back the pixel data in the exact format its created with, this function will be faster.

Another issue i had was that alot of NVidia cards (again, unlike my Radeon) would have issues trying to create a window with destination alpha, which meant i had to either draw and read a stencil buffer, or do a color mask...
Well, is your idea bound by the concept that the use still gets to interact with their desktop, or is it more of a novelty screen saver idea?

You could always do like the old screensavers did: screenshot the desktop and use it as your window, and feel free to go to town on it.
To do it in .Net would be quite simple.
First change the Transparency Key to a color, then make the Device Clear to that color. Windows Forms would then ignore any pixels designated in that color, showing whatever is behind.
Quote:Original post by Exorcist
One thing that i have implemented in an openGL rubix-cube program, was a mode that cuts away the window around the model. It does this via a glReadPixels and then uses that data to fill a "window region" object (look it up in the MSDN).

This works with a few caveats:

the glReadPixels call is usually slow by its functionality. however i found that ATI cards are at a extreme advantage over NVidia cards on this; My Radeon 9600XT would peform this call without a performance hit, unlike every GeForce card ive tried.

Also, by keeping your window as small as possible, and reading back the pixel data in the exact format its created with, this function will be faster.

Another issue i had was that alot of NVidia cards (again, unlike my Radeon) would have issues trying to create a window with destination alpha, which meant i had to either draw and read a stencil buffer, or do a color mask...


On the glReadPixels performance you should read this document: http://developer.nvidia.com/object/fast_texture_transfers.html

If you have trouble selecting a pixelformat with destination alpha that may either be 16 bit high color or you're missing something in your code.
NVIDIA offers pixelformats with and without alpha, ATI might only offer formats with alpha, which means you need to be careful to select precisely.
Choose PixelFormat is pretty buggy. DescribePixelFormat() is all you need to write your own enumeration.
If you use GLUT don't get fooled by the GLUT_RGBA define, its actually defined as GLUT_RGB and you need to add GLUT_ALPHA to get destination alpha planes.
(sorry cfolks, not trying to highjack your thread)

@Metalcore: Im not using GLUT, but yeah ive noticed some bugs with ChoosePixelFormat. I think i worked out what my case was, i had been implying 32-bit colour which on my ATI card implies 24-bit colour and 8-bit alpha; i hadnt explicitly specified the size of the alpha buffer. Thanks for that link too.

This topic is closed to new replies.

Advertisement