PDA

View Full Version : glReadPixels error



SagoO
04-04-2011, 09:07 AM
/*Read values back*/
/*Set the target framebuffer to read*/
glReadBuffer(GL_FRONT);
/*Read the packet payload from framebuffer to PBO*/
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboread);
glReadPixels(0,0,size,noOfpacket,GL_RED,GL_UNSIGNE D_BYTE,0);
checkError("Readpixel");
printf("Data after roundtrip:\n");

/*Map the PBO to process the data by CPU*/
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboread);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,noOfpacke t*size,result,GL_STREAM_READ_ARB);
for (i=0; i<noOfpacket*size; i++)
printf("%c",result[i]);
printf("\n\n");
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);


It returns me GL Error: Invalid enumerant. I cant find this error from the glReadPixels functions.

Here is the function check code:



void checkError(char *str)
{
GLenum error;

if ((error = glGetError()) != GL_NO_ERROR)
printf("GL Error: %s (%s)\n", gluErrorString(error), str);
}


This is GL error but not the function error right? Why?

mhagain
04-04-2011, 09:59 AM
Read the documentation (http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml) - glGetError doesn't necessarily return an error from the function immediately preceding it. There's no evidence that it was glReadPixels that threw the error; in fact if this is the only place you call glGetError in your code the function that caused the error could be anywhere.