View Full Version : glReadPixels and ppm

02-03-2004, 11:50 AM
I am trying to write a ppm file after obtaining the pixel information of the image i am displaying.

How should I go about using glReadPixels?

What data type should the array be storing (i.e. the array the data is read into)?

How do I get the integer values out of the array to write the ppm?

Thanks for any help!

02-03-2004, 02:39 PM
PPM has an interleaved format with RGB decimal, but runs top to bottom. It's actually an ASCII format.

The simplest approach is probably just to read GL_RGB packed unsigned bytes and loop through with a byte pointer writing out the rgb in byte order with newlines are appropriate places. You'll have to start at the last OpenGL line and work forward since OpenGL will read bottom to top first, but both are left to right at least.