如何从我的 EAGLLayer 中获取图像? [英] How do I grab an image from my EAGLLayer ?

查看:17
本文介绍了如何从我的 EAGLLayer 中获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找方法来获取我的 opengl(作为 UIImage)的内容,然后将其保存到文件中.我现在正在尝试 glReadPixels,尽管我不确定我是否在做正确的事情,我应该做什么样的 malloc.我收集到在 OSX 上它是 GL_BGRA 但在 iPhone 上不起作用......

I'm looking for way to grab the content of my opengl (as UIImage) and then save it into a file. I'm now giving glReadPixels a try though I'm not sure I'm doing the right thing as of what kind of malloc I should be doing. I gather that on OSX it's GL_BGRA but on the iPhone that doesn't work...

推荐答案

所有 OpenGL|ES 兼容的 GL 实现都必须支持 GL_RGBA 作为 glReadPixels 的参数.

All OpenGL|ES complient GL-implementations have to support GL_RGBA as a parameter to glReadPixels.

如果你的 OpenGL|Es 支持

If your OpenGL|Es supports the

GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 

extension 你也可以查询原生格式.glReadPixels 会将此格式理解为 glReadPixels 的参数,并允许您直接获取本机格式的像素数据.这通常比 GL_RGBA 快一点.

extension you can also query the native format. glReadPixels will understand this format as a parameter to glReadPixels and allows you to directly get the pixel-data in native format. This is usually a bit faster than GL_RGBA.

查看头文件或通过 glGetString 查询扩展支持.

Take a look at the header-file or query the extension-support via glGetString.

这篇关于如何从我的 EAGLLayer 中获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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