How to download image BACK from OpenGL?

I managed to load the image into OpenGL as a texture (I use Gdk :: Pixbuf from the GTKmm library), but I have no idea how to get the modified image from OpenGL and load it into Gdk :: Pixbuf ...

I want to modify images in OpenGL and save them to my hard drive.

There is some code:

Glib::RefPtr<Gdk::Pixbuf> pixmap = Gdk::Pixbuf::create_from_file("image.jpg"); GLuint texture[1]; glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, pixmap->get_width(), pixmap->get_height(), 0, GL_RGB, GL_UNSIGNED_BYTE, pixmap->get_pixels() ); 
+4
source share
3 answers

Edit the textured square to the framebuffer and then glReadPixels() .

+4
source

As long as you are not using OpenGL ES, but the real OpenGL desktop, you can simply use glGetTexImage .

+4
source

If you want to avoid the draw call, you can create a framebuffer and attach a texture to the color attachment, then use glReadPixels

0
source

All Articles