I am trying to save an image to file and am using:

glReadPixels(x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, image);

to capture the screen in to a temporary buffer, but when i compile the program i get an error saying that GL_BGR is an undeclared identifier. I am including gl.h, glu.h and glut.h and linking their corresponding libraries. Could someone please help.



depending on your Viedeocard, bgr might not be supported.

You could try using BGR_EXT, its supprted by NVIDIA cards .

Hope it helps

You’ll need the glext.h file, which can be found on this site, or nVidia’s developer page. The default Microsoft implementation supports the GL_BGR_EXT extension, and as far as I know any card you’re using under Windows should support it as well. I’m thinking that the gl.h that comes with VC++ actually includes the definitions for GL_BGR_EXT and GL_BGRA_EXT because they are listed in the MSDN documentation. Am I to assume you aren’t using VC++ and/or Windows? If you’re not using Windows, you should probably check the extensions string returned by glGetString(GL_EXTENSIONS) to make sure that extension is supported. That is probably a good idea under Windows too, but probably not really necessary.