FBO and Render To Texture = no alpha ?

Started by
0 comments, last by carmellose 15 years, 6 months ago
hi guys, i'm trying to do a simple RTT - render to texture - with a FBO - frame buffer object -. I can manage to do it, but it does not work whenever the texture has alpha : e.g. it seems the alpha is not copyed into the FBO. So the RTT works but wihtout the "alpha channel". Could you guys tell me how do i do an RTT with an FBO when my texture has alpha ? many thanks in advance.
Advertisement
up

i've been trying to do the following, but no effect at all (i use a shader so that's why the scene rendering contains "passes") :

void DrawObject(void) {  glClear(GL_COLOR_BUFFER_BIT);  glLoadIdentity();  /* draw a simple triangle and bind texture coordinates */  glPushMatrix();  glBegin(GL_TRIANGLES);  glTexCoord3f(0, 0, -1);  glVertex3f(-0.8, 0.8, -1);  glTexCoord3f(1, 0, -1);  glVertex3f(0.8, 0.8, -1);  glTexCoord3f(0.5, 1, -1);  glVertex3f(0.0, -0.8, -1);  glEnd();  glPopMatrix();}void RenderToTexture (void) {  // create objects  glGenFramebuffersEXT(1, &myFBO);// frame buffer  glGenRenderbuffersEXT(1, &myRBF);// frame buffer  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFBO);  // initialize texture  glBindTexture(GL_TEXTURE_2D, TEX_SCENE_SOURCE_IMAGE );  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,       sourceW, sourceH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);  // attach texture to framebuffercolor buffer  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,      GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, TEX_SCENE_SOURCE_IMAGE, 0);  // initialize depth renderbuffer  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, myRBF);  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA ,sourceW ,sourceH);    // attach renderbuffer to framebufferdepth buffer  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, myRBF);  CHECK_FRAMEBUFFER_STATUS();  //render to the FBO  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFBO);  // (draw something here, rendering to texture)  glPushAttrib(GL_VIEWPORT_BIT);  glViewport(0,0,sourceW,sourceH );  DrawObject();  glPopAttrib();  // render to the window, using the texture  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);  glBindTexture(GL_TEXTURE_2D, TEX_SCENE_SOURCE_IMAGE );}/* * main routine to display openGL scene * */void DrawGLScene(void) {  CGpass pass;  if ( t++ == 0) {    printf("[+] Render To Texture ...\n");    RenderToTexture();   }  pass = cgGetFirstPass(cgTechnique);  while(pass) {    cgSetPassState(pass);    /* Draw the scene as a texture */    glBegin(GL_QUADS);    glTexCoord3f(0, 0, -1);    glVertex3f	(-1,1 , -1);    glTexCoord3f(1, 0, -1);    glVertex3f	(1, 1, -1);    glTexCoord3f(1, 1, -1);    glVertex3f	(1, -1, -1);    glTexCoord3f(0, 1, -1);    glVertex3f	(-1, -1, -1);    glEnd();    cgResetPassState(pass);    pass = cgGetNextPass(pass);  }  glPopMatrix();  glutSwapBuffers();  return;	}


any advice on that ?

thank you ...

[Edited by - carmellose on October 11, 2008 4:42:06 AM]

This topic is closed to new replies.

Advertisement