OpenGL screenshot

Hi all, I'd like to add the possibility to take screenshots to my little OpenGL app, but I can't figure out how to do that. Generally I have no Idea whatsoever when it comes to save things to files... really I must have been creating completely useless software so far

Use glReadPixels() to capture the rendered buffer, then reformat the data and save it to a file in the image format you're most comfortable with (I use targa's, mostly because I use them for input as well, check out NEHE's tutorials for information on the format of targa files).

to be honest, I haven't yet found my way around cocoa or obj-c. my whole code is basically the cocoa-app template, but without the nib or main.m files. GLUT handles all the windowing stuff, and all my drawing and interaction functions. its all written in plain C. I don't think I can use all these fancy cocoa NSBitmap things without major overhaul of the whole thing, which is not what I really want to do.

I think a library which makes such tasks like saving a frame to a picture would be the most straightforward way, or am I wrong?

Yes, calling that function for each and every frame will drastically hamper your frame rate. It's meant as a snapshot function, not a recording function. If you want to record, then you'd probably do what Steven suggested: save all the data to a buffer, then dump the buffer into images/movie whenever the animation is done (or when memory is full).