PDA

View Full Version : GL_BITMAP w/ glReadPixels?



duhroach
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) ;
for(size*size)
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??

~Main

Relic
10-27-2003, 03: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.