Transparent OpenGL Windows

Just an idea… any comments on algo below…

  1. create window with WS_EX_LAYERED (or something like that)
  2. Create FBO or PBuffer
  3. render scene into pbuffer
  4. geta data back to cpu mem from pbuffer or map using copypixel or use FBO target
  5. create compatible dc and use it memory mapped with ABGR bits compatible with graphics data previously copied
  6. use updateLayeredWindow with alpha blending or color keying

Would this be reasonable fast ?

I have made tests with rendering using non double buffer + ws_ex_transparent to enforce obscured window repaint +savebits in window class but this flickers too much

Don’t want to copy background as i want to be able to move other windows around on the desktop that might be obscured by the ogl window…

Comments ??

Another question…

Is there a way to detect and copy the desktop dc + all rendered windows into a bitmap ? Can i get a hook on the desktop window and get the WM_PAINT to be able to keep a correct painted background of the dc ?

Hello there
Instead of you manually copying the desktop into buffer why don’t you try out the winapi functions SetLayeredWindowAttribute.
Signature is:
SetLayeredWindowAttribute(handle, color, transparency, LWA_ALPHA)
Parameters:
handle -> Your window handle (hWnd)
color -> Optionall set this to color that you want to be transparent or NULL
LWA_ALPHA -> constant for transparency

Try it out it worked for me. Moreover have a google out on this you will definitely get the source code too. (I got it in the same fashion :slight_smile:

Thanx
MMM

Just get a dark transparent window. No opengl in there.

Originally posted by ToolTech:
[b]Just an idea… any comments on algo below…

  1. create window with WS_EX_LAYERED (or something like that)
  2. Create FBO or PBuffer
  3. render scene into pbuffer
  4. geta data back to cpu mem from pbuffer or map using copypixel or use FBO target
  5. create compatible dc and use it memory mapped with ABGR bits compatible with graphics data previously copied
  6. use updateLayeredWindow with alpha blending or color keying
    […]

Comments ??[/b]
Check a previous post on that. Using FBOs or pbuffers instead of glReadPixels is just a variation.

I work on the same thing that you, but I cannot answer you for the moment I have a problem :
Alpha blending or color keying are applied
to my title bar but not on my opengl content.

Can you show me your PIXELFORMATDESCRIPTOR and any thing else to help me? Perhaps together we will find a good solution.

Thanks

try to render into a bitmap and redraw the window with that bitmap using a all black mask that you render into a bitmap

useing a bunch of bltbit calls you can draw it and use like black as your transparent mask color

i dought you will get really high framerates, but it is possible

to get rid of the flicker you make have to use a memory dc to render into and copy that into a dib and copy that into the window’s dc

there is going to be alot of steps involved per frame in this, and it will stress out the graphics accelerator
but it would be useful for something like a desktop pet dog or something like that
since you could use a model made in a 3d editor and just render it

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.