View Full Version : OpenGL window transparency and texture transparency

03-15-2002, 02:33 AM
Could anyone please tell me if it's possible and how to create an OpenGL window with a transparent background?
Other sugestions are wellcome.
And could someone please explain me how to make an RGBA texture mapped square with a transparent background draw on top of another image(RGBA texture mapped square), leaving the image behind be visible through the transparent part of the new image? I've tried blending with all combinations of glBlendFunc(...), but none gave me the results i wanted. Tried alpha testing with glAlphaFunc(...) and glEnable(GL_ALPHA_TEST) and i saw no change on the image(no transparency achieved).
Thank you.

03-15-2002, 03:21 AM
dont know about the windo w but try this link for transparent images

03-15-2002, 04:22 AM
I don't think OpenGL has any concept of 'stuff behind my viewport', so you can't directly blend into that. Your best bet would be to get the desktop image with OS specific means and draw that into your gl view, then blend over it.

03-15-2002, 08:08 AM
Perhaps i'm overlooking something, but the fact is that i have a PNG image with an alpha channel and it doesn't blend properly(the way i need it to): it doesn't get drawn over the background image as i like. I need to make the image draw 100% on top of the background except for the transparent part of the picture(like what i think is a sprite).Can someone tell me if there are some caveats in making this work? something related to glAlphaFunc(), glEnable(GL_ALPHA_TEST), GL_DEPTH_TEST, GL_BLEND?
And can someone explain me how the glBlendFunc() works? i've tried all combinations of values in gl.h and it doesn't work.....i've also tried using alpha testing insted of blending, but it does nothing....os simply makes the image on top of the background drawing the transparent part of the image in black.
I'm using IMG_Load() from the SDL_image library.

03-15-2002, 08:37 AM
You're probably not depth-sorting correctly. If you draw something behind a semi-transparent surface, it will fail the depth test.

There are two solutions: either disable depth writes and tests or sort back to front.

The general case works like this:
Draw solid geometry with depth writes/test enabled Draw transparent stuff back to front