glReadPixels error


/*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_UNSIGNED_BYTE,0);
checkError("Readpixel");
printf("Data after roundtrip:
");
	
/*Map the PBO to process the data by CPU*/
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboread);
	glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,noOfpacket*size,result,GL_STREAM_READ_ARB);
for (i=0; i<noOfpacket*size; i++)
        printf("%c",result[i]);
printf("

");
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)
", gluErrorString(error), str);
}

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

Read the documentation - 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.