简体   繁体   中英

How to load image BACK from OpenGL?

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

I want to modify images in OpenGL and the save them on hard disk.

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() );

将纹理四边形渲染到帧缓冲区,然后渲染glReadPixels()

只要你不使用OpenGL ES,但真正的桌面OpenGL,你就可以使用glGetTexImage

如果你想避免绘制调用,你可以创建一个帧缓冲并将纹理附加到颜色附件,然后使用glReadPixels

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM