PDA

View Full Version : glReadPixels and ppm



yage0832
02-03-2004, 12:50 PM
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!

dorbie
02-03-2004, 03: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.