Snapshot screen sapture

I basically need an example of code that will “grab” the frame that is currently displayed on the screen and write it out to a file. The ultimate goal is to be able to grab a series of frames that are being simulated on the screen, save them to files, create a playback tool, and then use the playback tool to recreate the “movie” effect.
Right now, I run a simulation that consists of multiple frames (comes to the screen as an animation) and I am looking to be able to basically record this simulation (in separate frame files) to be played back identically as it was the first time at a later date.
I am open to any suggestions b/c I may be looking at this problem from the wrong angle. I hope that someone can help as soon as possible!!!

The data can be read via glReadPixels(). Perform a search on this forum and you’ll find lots of hints.

Have a look at my last post in this thread for a nice way to read data FROM an AVI file.

With some changes (and lots of newly learned AVI data structures ) it might also be very comfortable to write those images you have into a single unpacked AVI file.

Hello, you can save u’r screen in a texture file like file.tga or file.rgb .
You will be able to use the animated textures to animate your movie.
To do it, u just have to get all the buffer and to put it into the file you want.
You can do it with the gl function:


The pseudo code is:

glBindTexture(GL_TEXTURE_2D, The_Texture_ID);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, hight);

Hope this helps


You could try saving the information about the objects in each frame to a file (such as their positions and rotations), and then when you play back the movie, just render them again using the information you saved.

Ah, I think I misinterpreted the question.
You want the real 3D data to be played again?

Depending on the hierachical structure of you data, you could store the objects and matrices,
or wrap every gl- and glu-function and extensions with an own version, which store the function ID and all parameter contents (including textures, bitmaps, vertex arrays … uh-oh, that’s going to be a huge file).