Alex Rivera | Logout

Can Vertex Array Objects (VAOs) be shared across EAGLContexts in OpenGL ES?

Asked 2011-08-19T17:33:24.543
21

Spoiler: I'm fairly confident that the answer is NO, but that's only after a day of very frustrated debugging. Now I would like to know if that is indeed the case (and if so, how I might have known), or if I'm just doing something completely wrong.

Here's the situation. I'm using OpenGL ES 2.0 to render some meshes that I load from various files (.obj, .md2, etc.). For the sake of performance and User Experience, I delegate the actual loading of these meshes and their associated textures to a background thread using GCD.

Per Apple's instructions, on each background thread, I create and set a new EAGLContext with the same shareGroup as the main rendering context. This allows OpenGL objects, like texture and buffer objects, that were created on the background thread to be immediately used by the context on the main thread.

This has been working out splendidly. Now, I recently learned about Vertex Array Objects as a way to cache the OpenGL state associated with rendering the contents of certain buffers. It looks nice, and reduces the boilerplate state checking and setting code required to render each mesh. On top of it all, Apple also recommends using them in their Best Practices for Working with Vertex Data guide.

But I was having serious issues getting the VAOs to work for me at all. Like I do with all loading, I would load the mesh from a file in

Edit
Report

1 Answer

22

According to this, OpenGL-ES explicitly disallows sharing of VAO objects:

Should vertex array objects be sharable across multiple OpenGL ES contexts?

RESOLVED: No. The OpenGL ES working group took a straw-poll and agreed that compatibility with OpenGL and ease of implementation were more important than creating the first non-shared named object in OpenGL ES.

As you noted, VBOs are still shareable, so you just have to create a VAO for each context that binds the shared VBO.

answered 2011-08-19T17:40:49.010

Your Answer