What exactly is shared between two NSOpenGLContexts?
I'm trying to create an NSOpenGLContext, initialize my rendering engine, then create new NSOpenGLContexts using the share parameter from the first context. This doesn't work, and before I go on, what exactly is shared between a context? The documentation is a little light on this:
Shared contexts share all texture objects, display lists, vertex programs, fragment programs, and buffer objects created before and after sharing is initiated. The state of the objects is also shared but not other context state, such as current color, texture coordinate settings, matrix and lighting settings, rasterization state, and texture environment settings.
When I create my first NSOpenGLContext, I initialize my rendering engine, which makes the following types of calls:
Most of those are for three types of tasks - creating vertex and shader programs, storing reference to attrib and uniform locations within the programs, creating vertex arrays, and binding a few textures.
Would you expect all of these items to be shared across contexts?
Function calls are not shared across context. Only objects. And only some objects.
In general, the objects that are shared are those that would be obviously prohibitive to have to re-create on another context. Either due to storing a lot of data, or relatively long setup time.
If you want a list, the following objects are shared:
Notable objects that aren't shared:
An object being shared means that it maintains all state across the contexts. So if you modify state from one context, you will see it in the other. However, this also means you must synchronize your access to shared GL objects if you're using multiple threads. Otherwise race conditions and other badness can occur.
链接地址: http://www.djcxy.com/p/38486.html