views:

568

answers:

2

hi I'm very much new to openGL and I'm trying to do a small project something like a paint tool.. so i just want to save all the things in frame buffer to be saved in a file and to retrieve them back..

+1  A: 

all the things in frame buffer?

If you are trying to capture the current image in the front/back buffers, glReadPixels (read a block of pixels from the frame buffer) along with glReadBuffer might be what you are looking for. see OpenGL manual. This is not necessarily the fastest way to do it, depending on the extensions you can use with the hardware you have there may be faster ways but glReadPixels is fairly straight forward to use. glDrawPixels will help you to get the data back into the framebuffer. You can just store the raw images to disk or convert/compress as you like.

Chris
A: 

If you wish to save all your objects to a file and load them back in, I do not believe you should be using OpenGL to do so. Once you send objects into OpenGL, you frequently don't modify them again. If you are writing some kind of application to draw many objects on screen, it would be easiest to just keep track of the objects yourself.

If you are looking to retrieve the final image, you can either use glReadPixels - to get the raw pixel data, or glCopyTexImage2D - to save what is on the screen into a texture for further use within OpenGL.

Andrei Krotkov