FBO issues

Hi,

I’m quite new to FBO’s but want to incorperate them into my 3d engine. I am unfortunatelly having a few problems.

What I am doing is this:

  1. Rendering my scene normally
  2. Turing on my FBO
  3. Rendering the scene again
  4. Turning off the FBO
  5. Adding an ortho overlay on the screen attempting to display the FBO texture.

The problem is that the only thing in the texture is white, no scenedata :frowning:

Here is some code showing how I set up the FBO (done once at initialisation):


    IntBuffer intBuffer = BufferUtils.createIntBuffer( 1 );
    EXTFramebufferObject.glGenFramebuffersEXT( intBuffer );
    myFBOId = intBuffer.get();

    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId );
    EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
                GL11.GL_TEXTURE_2D, textures[0].getTextureID(), 0);

    fboErrorCheck();
    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);

note: FBO error check just ensures completness

And each frame I do this:


1) Render scene normally, then:

    //Render to FBO
    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId );
    EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
                GL11.GL_TEXTURE_2D, textures[0].getTextureID(), 0);
    fboErrorCheck();

    GL11.glPushAttrib( GL11.GL_VIEWPORT_BIT );
    GL11.glViewport( 0, 0, 512, 512 );
    GL11.glClear( GL11.GL_COLOR_BUFFER_BIT );

    GL11.glPushMatrix();

    //configure camera
    GameManager.getCameraManager().getCamera( "main" ).lookAt();
    RenderScene();
   
    GL11.glPopMatrix();
    GL11.glPopAttrib();
    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);

    textures[0].bind();
    EnterOrtho();
    GL11.glBegin(GL11.GL_QUADS);
      GL11.glTexCoord2f( 0,1);
      GL11.glVertex2f(0, 200);
      GL11.glTexCoord2f( 1,1);
      GL11.glVertex2f(200, 200);
      GL11.glTexCoord2f( 1,0);
      GL11.glVertex2f(200, 0);
      GL11.glTexCoord2f( 0,0);
      GL11.glVertex2f(0, 0);
    GL11.glEnd();
    ExitOrtho();

I have been attempting to debug this issue for a few hours and I can’t seem to get anywhere no matter what I try. Any help would be greately apreciated. I am sure the bug in there is quite trivial; I just don’t have enough experience with FBO’s to spot it.

Looks like I can use FBO’s but I can’ activate texture units :confused:

This was my fix:

GL13.glActiveTexture( GL13.GL_TEXTURE0 );
GameManager.getGameManager().getRenderManager().bindFBOColourTexture(0);
GL11.glEnable( GL11.GL_TEXTURE_2D );

I forgot that I disabled my texture units after each pass :confused: