saving an OpenGL rendered window to a file

I’m not very OpenGL literate. I’m working on an OpenGL project and we need to save a picture of an OpenGL window to a .bmp or .jpeg file. Is this possible? If so, can someone point me in the right direction for information on it. Thank you


You can use glReadPixels() to copy the framebuffer to ram, then you need some code or a library to save the image to bmp or jpeg. has lots of information about different file formats.

libjpeg is a library that can read/write jpeg files, I don’t have any url handy, but give google a shoot.


Hi there

You can just press ctrl-alt-PrintScrn in the window (or try with ctrl-PrintScrn) and then go to something like Paint program and press ctrl-v (paste) then save that as a .bmp or .jpeg or whatever format you like.

Hope that helps!

that’s what we do now. The customer doesn’t want to have to do this. They want it automated. I’m not sure if it’s relevant, but we are coding in Ada for this.

Originally posted by wlkelley:
…but we are coding in Ada for this.

Uh-oh. I never used that language so I don’t know if this helps, but I put my advice on libpng. It is, by far, better documented than jpeg and widely recognized. Considering it’s unencumbered by patents and takes very little time to make it work, I would try to see if you are satisfied with it.

You can easily do it in 2-7 days on and off. If you do it full time, I guess you can cut it in 1-2 days. It is, really, so easy.