View Full Version : Rendering to the Desktop...How?
How to Render to the desktop using OpenGL?
03-27-2003, 04:40 AM
using Win32 there is a function called GetDesktopWnd() (name may be off...check it) this should get you the HWND for the desktop, then you can get the HDC for it and set up your HGLRC off of that.
03-27-2003, 05:27 AM
You're asking for trouble!
Remember, SetPixelformat can only be called once for the lifetime of a window.
The desktop window does not belong to your process, means you cannot destroy and recreate it.
DON'T ever call SetPixelFormat on GetDC(NULL).
I've seen it done before, i have a program which does it, so it's not impossible.
i tried to setup OpenGL using the handle return from GetDesktopWindow(), but nothing happened!!
so if anybody knows how to do it, please tell me........
sorry for my english,
03-27-2003, 03:42 PM
Doesn't winamp do that? Something about setting the desktop color.
03-27-2003, 04:23 PM
GetDesktopWindow return a HWND. Use GetDC(hWnd) to get the HDC for it and pass that to your context creation functions.
You will probably want to call InvalidateRect(hWnd, NULL, TRUE) when your application is closing so that the system will tell everything else to update. You may need to call UpdateWindow also. Otherwise, some things may look funny.
And, you should appreciate what Relic says. Be sure to call wglDeleteContext when your application closes also.
[This message has been edited by shinpaughp (edited 03-27-2003).]
03-31-2003, 06:27 AM
This program you describe will only run once! The second time you start it SetPixelformat will fail, because you already have called it before for that window.
I'm not aware of a way to dow this on the desktop window correctly, but there might be a possibility to do something like the animated desktops of web enhanced desktops do, but these are probably not using OpenGL.
No idea if it's possible to exchange the desktop window. E.g. the boot screen and the screen you get when pressing alt+ctrl+del will switch to a different desktop on NT. So maybe there is a way, but I don't know it, yet.
just a suggestion... maybe you could create another transparent window with same size as desktop and play with z-order to place it just above the desktop a then you could do whatever you want. (but it can be trouble with creating transparent gl window) if you don't worry about performace you could create offsren memory dc, render there and then blit it to your fake desktop window skipping pixels with some background colour (is it possible to render to memory dc via gl??)
as ususal, i may be wrong but there is also a little chance i'll be helpful http://www.opengl.org/discussion_boards/ubb/smile.gif
03-31-2003, 07:12 PM
yeah, with glReadPixels(), but it's slow. Maybe if you use the windows GDI, and copy the pixels from that. OpenGL renders to a window after all.
How does winamp uses transparency anyway? http://www.opengl.org/discussion_boards/ubb/smile.gif coudl be interesting to know.
[This message has been edited by oliii (edited 03-31-2003).]
03-31-2003, 07:25 PM
Winamp visualizations run really slow on the desktop. Usually to get a decent FPS, you have to enable pixel doubling.
03-31-2003, 10:27 PM
The desktop window belongs to the explorer process which is created by the local user logged on to the wkst. The explorer process is open for subclassing, hooks or injecting dlls. Some of those techniques should be enough for you to execute some code in that process. If you are interested in this type of system programming I suggest you pick up a copy of "Advanced Windows" by Jefferey Richter, it's a classic.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.