1

Possible Duplicate:
(win32) How to make an OpenGL rendering context with transparent background?

Hi,

Using OpenGL & Win32, I would like to create a dynamically updating semi-transparent window. Basically, what I really want is to have everything I don't actively render to in the frame (i.e. the "clear" color specified by glClearColor()) not be displayed as part of the window.

I've started out by creating a border-less window using Win32 functions (when I create the OpenGL window) so it will appear "floating", and use SetLayeredWindowAttributes with LWA_COLORKEY set to the clear color so it will automagically make pixels of that color transparent. That didn't work, still not sure why. Some ideas could help.

Later, I've tried getting from the frame buffer each pixel in the to-be-rendered image (since it's a double-buffered app, I believe this is the back buffer), and (tediously) composing an HREGION containing all the transparent pixel, and use SetWindowRgn() on the inverse of that outcome to achieve the desired effect. However, I could not successfully find any pixels with the "clear color" (set to pink = RGB(255,0,255)) anywhere in the image (not even a single pixel), even though more than 80% of the image was with that color. The window is on top of others so the pixels "belong" to that window, so I don't think that's the problem here. I also believe this solution (manually combining regions) is slow and will yield bad performance.

I have found samples on how to achieve "semi-transparent" windows where the transparency mask is achieved statically from a bitmap or similar, but didn't find a good example where the transparency changes per-frame.

Any help will be appreciated. Thanks.

Community
  • 1
  • 1
scooz
  • 828
  • 2
  • 7
  • 24
  • 2
    possible duplicate of [(win32) How to make an OpenGL rendering context with transparent background?](http://stackoverflow.com/questions/4052940/win32-how-to-make-an-opengl-rendering-context-with-transparent-background), See this answer: http://stackoverflow.com/questions/4052940/win32-how-to-make-an-opengl-rendering-context-with-transparent-background/4201472#4201472 – Yakov Galka Dec 12 '10 at 21:16
  • ybungalobill: It seems you are correct. From first examination, one of the samples works for a "static" drawing, still checking to work if it works for a per-frame basis. If so, how should I cancel my post / refer to the other? – scooz Dec 13 '10 at 14:05

0 Answers0