How to save a frame buffer and then put it back

Hi I am very new to openGL and I am trying to make a small project similar to a paint tool. So I just want to save all the stuff in the framebuffer to be saved to the file and get them back ..

0


a source to share


2 answers


all things in the framebuffer?



If you're trying to grab the current image in front / back buffers, glReadPixels (read a block of pixels from a framebuffer) along with glReadBuffer might be what you're looking for. see the 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 pretty straight forward to use. glDrawPixels helps you return data to the framebuffer. You can just save the raw images to disk or convert / compress as you like.

+1


a source


If you want to save all your objects to a file and load them back, I don't believe you should use OpenGL for that. When you submit objects to OpenGL, you often don't modify them again. If you are writing some kind of application to draw many objects on the screen, it would be easier to just keep track of the objects yourself.



If you want to get the final image, you can use glReadPixels - to get the raw pixel data, or glCopyTexImage2D - to save what's on the screen to a texture for later use in OpenGL.

0


a source







All Articles