openGL into png [英] openGL into png

查看:223
本文介绍了openGL into png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个openGL 包含很多纹理(没有移动)到一个PNG文件,我可以使用在另一部分框架我正在使用。是否有C ++库?

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?

谢谢!

推荐答案

如果你只是意味着获取由OpenGL渲染的场景并将其保存为图像,那么这是相当直接的。您需要使用glReadPixels()读取场景,然后将该数据转换为图像格式,例如PNG( http://www.opengl.org/resources/faq/technical/miscellaneous.htm )。

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).

还有更有效的实现方法,例如使用 FBO 。不是将场景直接渲染到帧缓冲区,而是通过FBO将其渲染到纹理,然后将该纹理渲染为全屏幕四分体。然后,您可以使用此纹理并将其保存到文件(使用 glGetTexImage a>)。

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).

这篇关于openGL into png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆