Hi,
I’m working with FBO to render in to textures. Before, i worked with NVidia 6800 and my app works fine using GL_TEXTURE_RECTANGLE_NV, but now I convert the code to work with GL_TEXTURE_2D, this supports both NVidia and ATI cards (i’m using 4 COLOR_ATTACHMENTs). After execute several computations using shaders (vertex and fragment) I use this data for rendering the scene, but the illumination is being affected by some OpenGL functionality, i don’t know that may be.
void render_scene() {
//bind the FBO, and the associated texture.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, imageWidth, 0, imageHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, imageWidth, imageHeight);
_shader1.use(true);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex[1]);
drawQuad();
_shader2.use(false);
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex[2]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex[3]);
drawQuad();
glReadPixels(0, 0, imageWidth, imageHeight, GL_RGBA, GL_FLOAT, data);
glUseProgram(0);
glDisable(GL_TEXTURE_2D);
// ‘unbind’ the FBO. things will now be drawn to screen as usual
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
setWindowState();
//—> Here is the problem, as if the light was being
// influenced by some shader program or texture
RenderObjects(data);
glutSwapBuffers();
}