Render To Texture Problem : No Alpha

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?

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).]

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.


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 
PFD_TYPE_RGBA,         // RGBA type 
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