Textures are not drawn if multiple EAGLViews are used.

I have a problem with Apples EAGLView and Texture2D. If I create an instance of EAGLView and draw some textures, it works fine. However, whenever I create a second instance of EAGLView, the textures are not displayed in the new view.
Being new to OpenGL, I understand exactly what causes this behavior. If someone wants to help, I created a small project that reproduces the behavior. The project can be found at http://www.cocoabeans.se/OpenGLESBug.zip

Many thanks,
Tim Andersson

Update
I tried to use groups, but I'm not sure if I used them correctly. However, this slightly changed the behavior; instead of a texture drawing only in the first instantiated representation, it now draws the texture in the last instantiated representation and draws white rectangles in other representations. I do not know if it is good or worse, but at least something appears in other views. It drives me crazy, and I would be very grateful if anyone would help me with this problem. I updated the project at http://www.cocoabeans.se/OpenGLESBug.zip to reflect the changes.

Cheers
Tim

Second update
After trying a few more things, it seems like the problem is with the Apple Texture2D class, although I'm not sure what exactly causes the behavior. I think it’s best to write your own texture class (this will help me understand how OpenGL handles textures, which is probably useful).

+4
source share
1 answer

(Did not load your code.)

OpenGL drawing contexts are different if you just use two EAGLViews (the code in this base class creates and owns the GL context, as well as render / frame / depth buffers). If you create / link some textures in one context, they will not be available in another. You can exchange contexts if you like to use sharegroup (see this question for more: How to use OpenGL ES in a separate stream on iphone? ). Or define textures (if they are small) in both places, etc.

+1
source

Source: https://habr.com/ru/post/1301477/


All Articles