Archived

This topic is now archived and is closed to further replies.

ThomW

Rendering To Desktop

Recommended Posts

ThomW    122
I''m not sure HOW to do it, but the way that other things work is through color keying. A cool program to see this at work is Drempels. http://www.geisswerks.com/drempels/index.html I''ll post more if I come across additional info. ThomW www.LMNOpc.com

Share this post


Link to post
Share on other sites
TheGilb    372
Ok I am not sure if these are the only ways to do it - the technique you use basically boils down to why you want a transparent background (Or even what you want the transparent background for ).

1) Grab desktop DC. GetDC(HWND_DESKTOP) or something like that *g* This will get you the DC of the desktop, essentially giving you a handle to the windows backbuffer I suppose! *g* It''s possible to draw directly to the desktop using GDI calls, or to grab the desktop, init DirectX at the current screen resolution and create a surface using the contents. This is how something like beavis and butthead screen-wreckers works.

2) Create a region with areas ''cut out'' of it. When you create a Win32 window it is possible to attach a region to it (Look up CreateRegion on MSDN) which has parts missing. This way, it is not only possible to see whatever is behind the window, but also to click on it. If you ever see a window with rounded edges it''s most probably done this way This is how something like cyber girl (Or whatever it''s called!) works.

3) Create a window with a background property of NULL. I think that''s right. If you create a window with no background at all, you''ll see a copy of the desktop on the window.

Thinking more about what you want to do, it might be possible to attach an OpenGL rendering context to the desktop window (HWND_DESKTOP)... I don''t know!

Hope this (rather limited) info helps at least a bit!

Share this post


Link to post
Share on other sites
feagle814    122
I think it would be pretty easy to render to the desktop, if you could find an offscreen rendering context:

First you need to find the Desktop DC as described above, then:

1) Create two device contexts compatible with the desktop
2) Create two bitmaps the size of your rendering context and select each to a device context
3) Set them to 32-bit color
4) Clear the stencil buffer to 0xFFFFFFFF
5) Clear the color buffer to black
6) Enable stencil writing and render
7) Call glReadPixels to get image information:
-Stencil buffer to one image
-Color buffer to the next
8) BitBlt from the Stencil to the Desktop using SRCAND
9) BitBlt from the Color to the Desktop using SRCPAINT

But how does one create an offscreen rendering context (i.e. a back buffer without a front buffer) ?

Share this post


Link to post
Share on other sites
Shag    122
Remeber that the desktop window has certain 'special' properties ... rendering to it isn't such a good idea - the usual trick is to make a bitmap copy of the desktop, and use the bitmap as a background to your own window ... check out the OpenGL forums at OpenGL.org - there was a similar post to this recently.

Oh Yeah ... remember that you can only use SetPixelFormat for a given window ONCE - and it's already been used by the windows GDI, which is incompatiable with OpenGL

Edited by - Shag on November 12, 2001 11:23:35 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
you ppl are talking about something you not have done and are theorizing the wrong way. Why do you need to render directly to the memory space of the desktop bmp? create regions for each window? no thanks, i want it run without eating cpu and cluttering the windows gdi. you are being blinded by your oblivous view of how tricks like this can be accomplished. the best method is to use directx (opengl aint designed for this stuff and could not hope to do this without dangerous methods that coudl cause Bad Things)

1. create non exclusive window mode sized to desktop resolution (exclusive mode is bad in this scenario because you dont need exclusive to perform the effect and it would interfere with other programs too much to be useful)
2. create back buffer
3. setup a dest color key (a color not used often) for your blit
4. set desktop color to said color
5. render to your back buffer and plit to primary using said color key as the dest color key
6. extra points for using overlays. careful not all cards support multiple overlays (actually i never came across one that does). also you may not have access to RGB surfaces (nvidia cards dont seem to support rgb overlays) and have to do rgb->yuv conversions which slows things down again.

as a word of caution, never try to do things that directly access windows structures unless you are 120% sure you know what you are doing and know exactly how all versions of windows deal with that structure.

for instance access dcs directly without going through the gdi is bad.

creating windows with null backgrounds is bad. (thats what WS_EX_TRANSPARENT is for).

glReadPixels (as all GetPicel type functions) are slow as a sloth in molassas. and not meant for full screen operations.

- groof
why do ppl use the wrong tools for the job because of prejudice?

Share this post


Link to post
Share on other sites
Shag    122
and how does that solve the problem of showing icons through?

I think maybe you misunderstood the question ... ThomW wanted to use the desktop to render to - DirectX doesn''t have any better solution than OpenGL!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
It''s strange... I''ve seen a few posters with the nick "Anonymous Poster" and they (plural or singular I''m not sure) always seem to have an inflated ego and an overblown sense of their own intelligence compared to others.

Share this post


Link to post
Share on other sites