如何在iphone上的单独线程上使用OpenGL ES? [英] How to use OpenGL ES on a separate thread on iphone?

查看:177
本文介绍了如何在iphone上的单独线程上使用OpenGL ES?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL ES渲染循环放在我的iphone应用程序中的一个单独的线程上。除了EAGLContext的presentRenderbuffer方法失败之外,一切都很顺利。结果是一个空白的白色屏幕。
当在主线程上运行相同的代码时,presentRenderbuffer会成功并且图形会正确显示。
在单独的线程上执行OpenGL的正确方法是什么?

The OpenGL ES rendering loop is placed on a separate thread in my iphone application. Everything goes fine except that the EAGLContext's presentRenderbuffer method fails. The result is a blank white screen. When the same code is run on the main thread, presentRenderbuffer succeeds and the graphics is properly shown. What is the correct way of doing OpenGL on a separate thread?

推荐答案

你需要创建一个 EAGLSharegroup

查看此主题在线程之间共享OpenGL上下文。

Check out this thread on sharing OpenGL contexts between threads.

UPDATE

iOS5之前我在线程之间共享OpenGL上下文,允许从磁盘异步加载纹理。但iOS5的 CVOpenGLESTextureCaches 基本上使纹理上传免费,所以我不再需要shareGroups,我的代码更简单,更快。

UPDATE
Previous to iOS5 I shared OpenGL contexts between threads to allow asynchronous loading of textures from disk. But iOS5's CVOpenGLESTextureCaches essentially make texture uploads free so I don't need shareGroups anymore and my code is simpler and faster.

这篇关于如何在iphone上的单独线程上使用OpenGL ES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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