View Full Version : Render To Texture Problem : No Alpha

11-01-2003, 02:38 PM
Hi, im using a render to texture method to accuratly position a 3D realtime rendered sprite in a 2D environment - I want to alpha mask the "sprite" onto the background of the main scene. I am following a tutorial and have my blank texture space and glCopyTexImage2D functions using GL_RGBA. But when i come to use the texture on a quad in the main scene, the alpha information has gone, just the colour of the texture and the alpha value of the previous glColor command. Im a being stupid, or has anyone else had this problem?

11-01-2003, 02:59 PM
The problem may be that your texture has no alpha channel, or your current's collor alpha is 0. Set it to 1 (before aplying the texture) with

glColor4f(r, g, b, 1);

Then render. Now your texture will have alpha.

[This message has been edited by fuxifuxi (edited 11-01-2003).]

11-01-2003, 04:01 PM
another problem might be that you need to have destination alpha, the framebuffer has to have an alpha channel. And for this, you _must_ have at least 32 bpp, it won't work with 16.


11-02-2003, 02:25 AM
I fixed the problem - i had no alpha support in my Pixelformat descriptor - I had 32 bit color. OpenGL could use Alpha transparency internally and for textures loaded with alpha channels, but when using glCopyImage2D the framebuffer ( setup by pfd ) had no alpha channel so when the framebuffer was copied to a texture the alpha information was lost. I changed my PIXELFORMATDESCRIPTOR to having 24 bit color space and 8 bit alpha space and it now works.

sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
24, // #!# Important 24 bits of color RGB
0, 0, 0, 0, 0, 0, // 8-bit color bits ignored
8, // #!# Important 8 bits of alpha - if you want true alpha useage and not just internal opengl blending - this is needed.
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
0, // 32-bit z-buffer
0, // stencil buffer
0, // auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored