i draw a rectangle on the screen.
i use glReadPixels (0,0,400,600,GL_RGB,GL_UNSIGNED_BYTE,buffer)
to read the pixel values.
when i write the contents of buffer to a file, the file contains all I’s [ some dots on top of I ]. why is this? why am i not able to read the pixel values. and why is the file containing all same characters when i write to it?
Originally posted by dummy_24:
[b]somebody plzz help me with this
unsigned char buffer =[4006003]
i draw a rectangle on the screen.
i use glReadPixels (0,0,400,600,GL_RGB,GL_UNSIGNED_BYTE,buffer)
to read the pixel values.
when i write the contents of buffer to a file, the file contains all I’s [ some dots on top of I ]. why is this? why am i not able to read the pixel values. and why is the file containing all same characters when i write to it?[/b]
shouldnt there be a pointer to “buffer” (&buffer / *buffer). its been sometime since i programmed in c/c++
nope, i am not using them anytime, anywhere. i read glReadPixels(…) does all the work of copying pixel information from the frame buffer into the declared array.
Did you examine the readback buffer before dumping it to a file? Maybe ReadPixels returned the “correct” data, but you are writing/viewing it incorrectly?
Originally posted by mithun_daa: glReadBuffer back/front. are you setting this one right?
Most of the time you shouldn’t have to touch ReadBuffer since it is initialized automatically. For a single buffered fb ReadBuffer defaults to GL_FRONT and for double buffering it defaults to GL_BACK.