so what my code does
a) I render the teapot to FBO 1 (in HDR)
b) I render with a tonemapping pass to FBO 2
c) I draw a quad with the info from the FBO
Now I have an angle variable at the drawing of the quad and if I press 4 or 6 on my keyboard the angle changes. And so does the avg luminance of the image so it’s actually being rotated but this rotation does not show on the screen. Anyone any idea why the updated buffer is not drawn to the screen?
This is my display code
void display()
{
//Basic rendering to FBO 1
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(dsqrt3,dsqrt3,d*sqrt3,
0.0,0.0,0.0,
0.0,1.0,0.0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0].fbobj);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
bindCgPrograms();
glPushMatrix();
glRotatef(angle,0.0,1.0,0.0);
glutSolidTeapot(1.0);
glPopMatrix();
unBindCgPrograms();
glDisable(GL_DEPTH);
//Postprocessing
std::cout<<“START POSTPROCESSING”<<std::endl;
glColor3f(1, 1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
//glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
//Calculate average Luminance
float* data = (float*)malloc(fbo_width*fbo_height*sizeof(float));
//glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0,0,fbo_width,fbo_height,GL_LUMINANCE,GL_FLOAT,data);
int j =0;
std::cout<<j<<std::endl;
float subtotal = 0;
float delta = 0.001;
int t = 0;
for(int i=0; i<fbo_height*fbo_width; i++){
if(data[i] >= 0){
subtotal += log(delta + data[i]);
}
}
avg_luminance = exp(subtotal/(fbo_width*fbo_height));
std::cout<<subtotal<<std::endl;
std::cout<<avg_luminance<<std::endl;
//Render to FBO 2
glBindTexture(GL_TEXTURE_2D,fb[0].texobj);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[1].fbobj);
setTonemapParam(fb[0].texobj, avg_luminance);
bindTonemapCgPrograms();
DrawFullScreenQuad(fbo_width, fbo_height);
//Render to screen
glBindTexture(GL_TEXTURE_2D, fb[1].texobj);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
DrawFullScreenQuad(fbo_width, fbo_height);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
std::cout<<"angle "<<angle<<std::endl;
glutSwapBuffers();
//glFlush();
}