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

查看:23
本文介绍了如何在 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.

更新
在 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天全站免登陆