Advertisement Jump to content
Sign in to follow this  

FBO & RTT problem

This topic is 4092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im having some problems trying to render my scene to a texture. Here is my initialization code
    glGenTextures(1, &textura_fbo);
    glBindTexture(GL_TEXTURE_2D, textura_fbo);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w_size, h_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

    glGenRenderbuffersEXT(1, &depthbuffer);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer);

    glGenFramebuffersEXT(1, &fbo);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

     //definmos nuestro renderbuffer
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, w_size, h_size);

     //añadimos el renderbuffer al frambuffer

    //añadimos una textura
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textura_fbo, 0);
    //glBindTexture(GL_TEXTURE_2D, 0);
    //comprobamos si hay errores
    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

I check the status and im not getting any errors. Here ara my binding and unbinding fbo code
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
    //glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textura_fbo, 0);
    glViewport(0, 0, w_size, h_size);

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

And the render texture code
    glBindTexture(GL_TEXTURE_2D, textura_fbo);

    // Set Flags

    glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    glPushMatrix(); // Store The Projection Matrix

    // Change to orthogonal projection to do a texture blitter to the screen
    glLoadIdentity(); // Reset The Projection Matrix
    glOrtho(0,0,0,0,0,2000); // Set Up An Ortho Screen

    glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
    glPushMatrix(); // Store The Modelview Matrix
    glLoadIdentity(); // Reset The Modelview Matrix

    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(-1.0f, -1.0f, 0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f( 1.0f, -1.0f, 0.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f( 1.0f,  1.0f, 0.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(-1.0f,  1.0f, 0.0f);


    glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    glPopMatrix(); // Restore The Old Projection Matrix

    glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
    glPopMatrix(); // Restore The Old Projection Matrix*/

Now my problem is if i coment this line on init fbos procedure:

i can see my scene without depth testing, but with it i see a black screen. Any idea? Thanks in advance.

Share this post

Link to post
Share on other sites
I can't understand you're even seeing something, there's something really wrong with this line :


You're creating an orthographic projection as a 0-sized rectangle. If is ever does something, I could only expect it to show the single pixel located at (0, 0). Also, you're drawing your quad at z-depth 0, when your orthographic projection ranges from (0 to 2000), it's risky. If I was you, I'd change this line for :

glOrtho(0, 1, 0, 1, -1, 1);

Maybe your thing works, but I wouldn't bet on it.

Share this post

Link to post
Share on other sites
Yes, it was a mistake.

The FBO initialization procedure didnt give me any error, so i suspose that it moust be on render texture procedure, and thats why i started playing with glortho and gluperspective values. that mistake was one of this.

I continue playing with this but im not get it working when i set the glFramebufferRenderbufferEXT.

Thanks for your answer.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!