View Full Version : GL_BITMAP w/ glReadPixels?

10-24-2003, 08:05 PM
Howdy. I want to get a 0&1 representation of the screen (screen is rendered w/o texturing and lighting) can i do this using GL_BITMAP?
I do the following, but some elements in my array show up as neither 0 or 1..

bool array[size*size]
glReadPixels(0,0,size,size,GL_RED,GL_BITMAP,array) ;
if(array[i]) print("1");
else if(!array[i]) print("0");
else print("x");

i'm getting a ton of x's on the screen. shouldn't GL_BITMAP only give 0's and 1s? what's wrong??


10-27-2003, 02:53 AM
The question you should ask yourself is: What type is C++'s "bool" in machine words?
Use GLubyte array[(size*size+7)/8] instead of "bool" and interpret the resulting values bitwise from high to low bit.
Make sure you pack parameters are set to 1 if size is not a multiple of 4.