JT
07-14-2005, 11:57 AM
I am using glut for window management. For my application I would like to do offscreen rendering, so I am currently using glReadPixel() to pull pixel data from the framebuffer. However, this kills my framerate. This drops it to 7 FPS from 1500 FPS. Any suggestions on how to speed up the glReadPixel() function? I've tried disabling unnecessary states, but to no avail.
Following are my init and draw functions:
void init(void)
{
glClearColor(0, 0, 0, 0);
glShadeModel(GL_FLAT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
glPixelStorei(GL_PACK_ALIGNMENT, 8);
glDisable(GL_LIGHTING);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glReadBuffer(GL_BACK);
}
void drawStuff(void)
{
glPushMatrix();
glRotatef(rot,0.0f,1.0f,0.0f); glutWireSphere(1,20,20);
glPopMatrix();
}
void display(void)
{
glClearGL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
drawStuff();
glReadPixels( 0, 0, glWIDTH, glHEIGHT, GL_LUMINANCE, GL_FLOAT, bufferImage);
FPS(); glutSwapBuffers();
}
Following are my init and draw functions:
void init(void)
{
glClearColor(0, 0, 0, 0);
glShadeModel(GL_FLAT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
glPixelStorei(GL_PACK_ALIGNMENT, 8);
glDisable(GL_LIGHTING);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glReadBuffer(GL_BACK);
}
void drawStuff(void)
{
glPushMatrix();
glRotatef(rot,0.0f,1.0f,0.0f); glutWireSphere(1,20,20);
glPopMatrix();
}
void display(void)
{
glClearGL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
drawStuff();
glReadPixels( 0, 0, glWIDTH, glHEIGHT, GL_LUMINANCE, GL_FLOAT, bufferImage);
FPS(); glutSwapBuffers();
}