I’m trying to get a FBO to work for my program. I think I understand how to set up and use it, but I’ve got a problem with drawing to it. Here’s the relevant code (Pascal):
Setting up the FBO and attaching a texture:
glGenTextures(1, @TextureID[FBOMap]);
TextureDimX[FBOMap] := 512;
TextureDimY[FBOMap] := 512;
glBindTexture(GL_TEXTURE_2D, TextureID[FBOMap]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureDimX[FBOMap], TextureDimY[FBOMap], 0, GL_RGBA, GL_UNSIGNED_BYTE, NIL);
glGenFramebuffersEXT(1, @FBO);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, FBOMap, 0);
Drawing to the FBO’s texture:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO);
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, 512, 512);
DrawToScreen(ShipsMap, 0, 0, 512, 512, 0, 0, 1, 1, 1, 1, 100, F, F); // This is just my screen drawing routine.
glPopAttrib();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Drawing the texture to the screen buffer in the main loop:
DrawToScreenAtCenter(FBOMap, 0, 0, 512, 512, 300, 300, 1, 1, 1, 1, 100, F, F, 0);
Now, if I attach a picture to the FBOMap texture when setting it up instead of giving NIL pixels, that picture shows up fine when rendering the texture to the screen, which makes me believe that I’m simply doing something wrong when setting the FBO as the draw buffer and drawing to it.
Can anybody see anything obviously wrong?