如果使用多个EAGLView,则纹理不会绘制 [英] Textures not drawing if multiple EAGLViews are used

查看:110
本文介绍了如果使用多个EAGLView,则纹理不会绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Apple EAGLView和Texture2D有点问题.如果我创建EAGLView实例并绘制一些纹理,则效果很好.但是,每当我创建EAGLView的第二个实例时,都不会在新视图中绘制纹理.
作为OpenGL的新手,我现在已经完全了解导致这种现象的原因.如果有人愿意提供帮助,我已经创建了一个小项目,可以重现该行为.该项目可以在 http://www.cocoabeans.se/OpenGLESBug.zip

I'm having a bit of a problem with Apples EAGLView and Texture2D. If I create an instance of EAGLView and draw some textures, it works great. However, whenever I create a second instance of EAGLView, the textures in the new view(s) aren't drawn.
Being new to OpenGL, I've got absolutely now clue as to what is causing this behavior. If somebody would like to help, I've created a small project that reproduces the behavior. The project can be found at http://www.cocoabeans.se/OpenGLESBug.zip

非常感谢,
蒂姆·安德森(Tim Andersson)

Many thanks,
Tim Andersson

更新
我尝试使用共享组,但是我不确定是否正确使用了共享组.但是,它的确改变了行为.现在,它不再在第一个实例化视图中绘制纹理,而是在 last 实例化视图中绘制纹理,并在其他视图中绘制白色矩形.我不知道这是好是坏,但现在至少在其他视图中显示了某事.
这让我发疯,如果有人可以帮助我解决这个问题,我将不胜感激.我已经在 http://www.cocoabeans.se/OpenGLESBug.zip 上更新了该项目.反映变化.

Update
I tried using sharegroups but I'm not really sure if I used them correctly. However, it did change the behavior slightly; instead of the texture drawing only in the first instantiated view, it now draws the texture in the last instantiated view and draws white rectangles in the other views. I don't know if that is better or worse, but at least something is showing up in the other views now.
This is driving me crazy and I would be very grateful if somebody could help me with this problem. I've updated the project at http://www.cocoabeans.se/OpenGLESBug.zip to reflect the changes.

干杯,
蒂姆

第二次更新
经过更多尝试之后,问题似乎与Apple的Texture2D类有关,尽管我不确定是什么导致了此问题.我认为最好的方法是编写自己的纹理类(这将帮助我了解OpenGL如何处理纹理,这可能会派上用场).

Second Update
After trying some more things, it seems that the problem is related to Apple's Texture2D class, though I'm not sure exactly what is causing the behavior. I think the best thing to do is to write my own texture class (it will help me understand how OpenGL handles textures, which will probably come in handy).

推荐答案

(尚未下载您的代码.)

(Haven't downloaded your code.)

如果仅使用两个EAGLView,则OpenGL绘图上下文会有所不同(该基类中的代码创建并拥有GL上下文以及渲染/帧/深度缓冲区).如果您在一个上下文中生成/绑定某些纹理,则它们在另一上下文中将不可用.如果您喜欢使用共享组,则可以共享上下文(有关更多信息,请参见此问题:

The OpenGL drawing contexts are different if you just use two EAGLViews (the code in that base class creates and owns the GL context as well as render/frame/depth buffers). If you generate/bind some textures in one context, they won't be available in the other. You can share contexts if you like using a sharegroup (see this question for more: How to use OpenGL ES on a separate thread on iphone?). Or define the textures (if small) in both places, etc.

这篇关于如果使用多个EAGLView,则纹理不会绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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