So far I've succeeded in creating my framebuffer object and target texture based on the example block at the bottom of http://www.songho.ca...gl/gl_fbo.html. After that, I've attempted various configurations of drawing what I want to the texture, but all I can seem to manage is to draw an opaque quad to it. I can't seem to get depth, alpha blending, or even texture mapping to work properly (no matter how I map the texture coords, the result is the same). glClear(GL_COLOR_BUFFER_BIT) on the texture causes my whole scene to get messed up, as well. The following code demonstrates how I'm trying to set up rendering to the texture:
glPushMatrix(); // set rendering destination to FBO glBindFramebuffer(GL_FRAMEBUFFER, 92); glViewport(0,0,screen_width, screen_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Clearing buffers glClearDepth(1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_DEPTH_BUFFER_BIT); // Clearing the GL_COLOR_BUFFER_BIT causes things to break // Set up internal rendering projection glOrtho(-0.5 * width, 0.5*width, -1, 1, 1, 0); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); // Set blend func //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Draw stuff here! At the moment just trying to draw a couple overlapping quads as a proof of concept // Unbind fbo glBindFramebuffer(GL_FRAMEBUFFER, 0); glPopMatrix(); // Set scene-relative blending function. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // function for blending // Draw the rendered texture on top of the underlying scene glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, 90); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0f); glVertex3f(-0.1,-0.1,0.01); // Bottom-Left Vertex glTexCoord2f(1.0f, 0.0f); glVertex3f(0.1,-0.1,0.01); // Bottom-Right Vertex glTexCoord2f(1.0f, 1.0f); glVertex3f(0.1,0.1,0.01); // Top-Right Vertex glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.1,0.1,0.01); // Top-Left Vertex glEnd(); glDisable(GL_TEXTURE_2D);
Any help is greatly appreciated!






