如何从EAGLLayer抓取图像? [英] How do I grab an image from my EAGLLayer ?

查看:87
本文介绍了如何从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 | E支持

If your OpenGL|Es supports the

GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 

扩展名,您也可以查询本机格式. 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天全站免登陆