View Full Version : Reading Pixels from buffer

11-14-2000, 07:34 PM
I am having problems trying to read pixel data from the back buffer. The code I have is returning all 0's in my pixel array. Here is a bit of my code.

First I initialize all my arrays

glDrawArrays(GL_QUADS,0, NUMSURF*4);
glReadPixels(0,0,viewport(3),viewport(4),GL_COLOR_ INDEX,GL_UNSIGNED_BYTE,bits);

When I look at bits I am always getting 0's
Any help would be great. I know that I am drawing correctly because when I swap the buffers after this I can see what I am trying to read into bits.


11-14-2000, 08:42 PM
I'm guessing that you have an RGBA, not a color index, visual. Replace GL_COLOR_INDEX with GL_RGBA...

Also, check glGetError() (or use glutReportErrors in a GLUT app). If you're not getting a result, more than likely an error is occurring.

- Matt