PDA

View Full Version : saving an OpenGL rendered window to a file



wlkelley
11-03-2003, 04:39 AM
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

WK

mikael_aronsson
11-03-2003, 05:32 AM
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.
www.wotsit.org (http://www.wotsit.org) 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.

Mikael

jessica
11-03-2003, 07:30 AM
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!
Jess

wlkelley
11-03-2003, 09:28 AM
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.

Obli
11-03-2003, 11:07 AM
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.