I have problems using the glReadPixels/glDrawPixels functions. I geting strangle results. I am using this code:
static GLfloat pixelsColor1[512*512];
static GLfloat pixelsColor2[512*512];
static GLfloat pixelsDepth1[512*512];
static GLfloat pixelsDepth2[512*512];
auxSolidBox(5, 2, 3);
glFinish(); //force openGL to start render the scene.
glReadPixels(0, 0, 450, 450, GL_DEPTH_COMPONENT, GL_FLOAT, pixelsDepth1);
glReadPixels(0, 0, 450, 450, GL_RGB, GL_FLOAT, pixelsColor1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
auxSolidBox(6, 4, 8);
glFinish(); //force openGL to start render the scene.
glReadPixels(0, 0, 450, 450, GL_DEPTH_COMPONENT, GL_FLOAT, pixelsDepth2);
glReadPixels(0, 0, 450, 450, GL_RGB, GL_FLOAT, pixelsColor2);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glDrawPixels(450, 450, GL_DEPTH_COMPONENT, GL_FLOAT, pixelsDepth1);
glDrawPixels(450, 450, GL_RGB, GL_FLOAT, pixelsColor1);
glDrawPixels(450, 450, GL_DEPTH_COMPONENT, GL_FLOAT, pixelsDepth2);
glDrawPixels(450, 450, GL_RGB, GL_FLOAT, pixelsColor2);
I am geting distorted results. if i am using the glReadPixels and glDrawPixels command only onces, the problem disappears.
Please, Help me if you know what’s the problem.