EAGLContext,EAGLSharegroups,RenderBuffers,FrameBuffers,我的天哪! [英] EAGLContext, EAGLSharegroups, RenderBuffers, FrameBuffers, oh my!

查看:140
本文介绍了EAGLContext,EAGLSharegroups,RenderBuffers,FrameBuffers,我的天哪!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将头衔围绕iPhone OS上的OpenGL对象模型.我目前正在屏幕上渲染成几个不同的UIView(在CAEAGLayer上构建).我目前使用单独的EAGLContext来分别使用其中的每个,每个都有一个颜色渲染缓冲区和一个帧缓冲区.

I'm trying to wrap my head around the OpenGL object model on iPhone OS. I'm currently rendering into a few different UIViews (build on CAEAGLayers) on the screen. I currently have each of these as using separate EAGLContext, each of which has a color renderbuffer and a framebuffer.

我正在其中渲染相似的事物,并且我想在这些实例之间共享纹理以节省内存开销.

I'm rendering similar things in them, and I'd like to share textures between these instances to save memory overhead.

我目前的理解是,我可以使用相同的设置(一定数量的上下文,每个上下文都有一个FBO/RBO),但是如果我使用第一个的EAGLShareGroup生成后面的上下文,那么我可以简单地使用后面的第一个中的纹理名称(GLuints).这是正确的吗?

My current understanding is that I could use the same setup (some number of contexts, each with a FBO/RBO) but if I spawn the later ones using the EAGLShareGroup of the first one, then I can simply use the texture names (GLuints) from the first one in the later ones. Is this accurate?

如果是这种情况,我想接下来的问题是:成为共享组"有什么好处?我可以重用相同的上下文,然后将多个FBO/RBO附加到该上下文吗?我认为我正在与共享组的抽象层作斗争,该共享组似乎共享上下文所拥有的对象"(纹理和其他命名事物),而不共享状态"(矩阵,启用/禁用状态).

If this is the case, I guess the followup question is: what's the benefit to having it be a "sharegroup"? Could I just reuse the same context, and attach multiple FBOs/RBOs to that context? I think I'm struggling with the abstraction layer of a sharegroup, which seems to share "objects" (textures and other named things) but not "state" (matrices, enabled/disabled states) which are owned by the context.

想到这一点的最佳方法是什么?

What's the best way to think of this?

感谢您的启发!

推荐答案

是正确的-使用相同的EAGLSharegroup创建两个EAGLContext时,它们共享相同的缓冲区对象,纹理,渲染缓冲区和帧缓冲区视图.如果您的上下文使用的是OpenGL ES 2.0,它们还将共享着色器和程序对象.

That’s correct—when two EAGLContexts are created with the same EAGLSharegroup, they share the same view of buffer objects, textures, renderbuffers, and framebuffers. If your contexts are using OpenGL ES 2.0, they’ll share shaders and program objects as well.

在使用同一共享组的多个上下文中,最大的用例之一是能够在渲染时从另一个线程异步加载资源.这似乎与您在此处执行的操作不一样,并且似乎不存在持久性上下文状态对您来说是个问题,因此您最好还是坚持使用单个EAGLContext并保存对其的引用所有可能需要它的对象都可以看到的地方.您只需绑定适当的帧缓冲区和颜色渲染缓冲区,即可更改要渲染的视图.

One of the biggest use cases for multiple contexts using the same sharegroup would be the ability to load resources asynchronously from another thread while you’re rendering. That doesn’t seem like what you’re doing here, and it doesn’t seem like having persistent context state is an issue for you, so you might be better off sticking with a single EAGLContext and just stashing the reference to it somewhere where all the objects that might need it can see it. You’d be able to change which views you’re rendering to simply by binding the appropriate framebuffer and color renderbuffer.

这篇关于EAGLContext,EAGLSharegroups,RenderBuffers,FrameBuffers,我的天哪!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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