Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openGL into png

Tags:

c++

png

opengl

ldf

I'm trying to convert an openGL [edit: "card that I drew"(?):) thx unwind]containing a lot of textures (nothing moving) into one PNG file that I can use in another part of the framework I'm working with. Is there a C++ library that does that?

thanks!

like image 535
majdal Avatar asked Dec 13 '22 05:12

majdal


1 Answers

If you simply mean "take a scene rendered by OpenGL and save it as an image," then it is fairly straightforward. You need to read the scene with glReadPixels(), and then convert that data to an image format such as PNG (http://www.opengl.org/resources/faq/technical/miscellaneous.htm).

There are also more efficient ways of achieving this, such as using FBOs. Instead of rendering the scene directly into the framebuffer, you can render it to a texture via an FBO, then render that texture as a full-screen quad. You can then take this texture and save it to a file (using glGetTexImage, for example).

like image 200
thekidder Avatar answered Dec 15 '22 20:12

thekidder