about GL_BITMAP

Dear all,

glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);

///////////////////////////////////////
glReadBuffer(GL_BACK);
unsigned char t0[2562564];
/////////////////////////////////
//it, save it with glReadPixels,
////////////////////////////////
glReadPixels(0,0,128,128,GL_COLOR_INDEX ,GL_BITMAP,t0);

but get nothing but a GL_INVALID_OPERATION error :confused: !

if I want get GL_BITMAP,so how can I do?

Thanks

You probably want:

glReadPixels(0,0,128,128,GL_RGBA,GL_UNSIGNED_BYTE,t0);

or

glReadPixels(0,0,128,128,GL_BGRA,GL_UNSIGNED_BYTE,t0);

(depending on how you want the RGBA valud ordered)

You can’t use GL_COLOR_INDEX on a RGBA surface (GLUT_RGBA)

Thanks I think so,but I want get bitmap by GL_BITMAP,so how can I do?

As he said, you cannot do that.

However, I suspect you’re confusing bitmaps as in BMP image files, with bitmaps as defined by OpenGL. They are not the same thing. A bitmap in OpenGL is a one bit image (therefore the name; bit-map), where a single bit represents, sort of, “pixel on” and “pixel off”.

To save a BMP image, you need to read back the image as sqrt[-1] said.

Yes,A bitmap in OpenGL is a one bit image ,How to get one bit image by GL_BITMAP?

Thanks Bob.

So let’s say it a third time; you can’t.

Two questions:

  1. Why do you want a 1-bit image? (what are you expecting? or what are you using it for?)

  2. Whay can’t you just convert the RGBA data to a 1-bit image yourself. (using the glReadPixels above to get the buffer then converting using whatever filter you need)

Two questions:

  1. Why do you want a 1-bit image? (what are you expecting? or what are you using it for?)

  2. Whay can’t you just convert the RGBA data to a 1-bit image yourself. (using the glReadPixels above to get the buffer then converting using whatever filter you need)