SoGLContext Class |
OpenGL context management class.
Namespace: OIV.Inventor.Devices
The SoGLContext type exposes the following members.
Name | Description | |
---|---|---|
![]() | SoGLContext(Boolean) | Constructor which creates an OIV.Inventor.Devices.SoGLContext based on the attributes of the current context. |
![]() | SoGLContext(SoGLContext, Boolean) | Constructor which creates an OIV.Inventor.Devices.SoGLContext based on the attributes of the specified context. |
Name | Description | |
---|---|---|
![]() | AssertContext | Assert this context and the current active context are the same. |
![]() | Bind | Bind this context to the current thread. |
![]() | Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) |
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() | GetContextFromId | Returns the context corresponding to an internal id. |
![]() ![]() | GetContextFromSharedId | Returns the first context that belongs to the specified sharedIdGroup. |
![]() | GetContextGraphicsCapabilities | Retrieve graphics capabilities from this context. |
![]() ![]() | GetCurrent | Calls GetCurrent(false). |
![]() ![]() | GetCurrent(Boolean) | Returns the current active OpenGL context (if any). |
![]() | GetFormat | Returns the OIV.Inventor.Devices.SoGLFormat associated to the OIV.Inventor.Devices.SoGLContext. |
![]() ![]() | GetGraphicsCapabilities | Retrieve graphics capabilities from the current bound context, if any. |
![]() | GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) |
![]() | GetId | Returns the internal id for this context. |
![]() | GetSharedGroup | Returns the current shared group. |
![]() ![]() | GetSharedGroupPolicy | Returns the current sharedGroupPolicy. |
![]() | GetSharedId | Returns an id common to all compatible/shared contexts. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Invalidate | Set this context as invalid so it won't be used anymore. |
![]() | IsCompatible | Returns true if two contexts are compatible. |
![]() | IsCurrent | Returns true if the context is valid and currently active. |
![]() | IsSharable | Returns the sharable status of this context. |
![]() | IsSharedWith | Returns the current sharing state with passed context. |
![]() | IsValid | Returns true if this context is valid. |
![]() | IsValidForCurrent | Returns true if the context is the current active context or if it is shared with the current active context. |
![]() | SetNoGLContextDelete | Prevent deletion of the native OpenGL context by OIV.Inventor.Devices.SoGLContext. |
![]() | SetSharable | Sets the sharable property. |
![]() | SetSharedGroup | Explicitly change the sharedGroup. |
![]() | SetSharedWith | Share this context. |
![]() | SwapBuffers | Swaps the buffers with the value stored in the OIV.Inventor.Devices.SoGLFormat, which is set to the main plane by default. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | TryBind | Try to bind the OpenGL context to the current thread. |
![]() | Unbind | Unbind this context from the current thread. |
Name | Description | |
---|---|---|
![]() | IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) |
This class provides functions to manage OpenGL device contexts.
The application can control sharing of OpenGL contexts. When you share OpenGL contexts, any context in that shared group can use GPU resources (such as textures, buffers, etc.) created in any other context in the group. This saves time and memory when rendering into multiple windows, buffers, etc. We recommend using context sharing when scene graphs are shared between multiple viewers. This approach saves memory on the GPU and improves rendering performance. To create a shared gl context, use a OIV.Inventor.Devices.SoGLContext constructor with the bool shared argument, and specify true.
In a typical Open Inventor application, the viewer class automatically creates an OpenGL device context and manages it for rendering and other GPU-related operations. However, this context is only made current when the viewer is actively using it, for example, to render the scene graph.
Do not assume that any OpenGL context is current. If you need a current OpenGL context, for example to create an OIV.Inventor.Devices.SoGpuBufferObject, () and () an OIV.Inventor.Devices.SoGLContext object.
If your application uses an Open Inventor viewer, the viewer's rendering context can be made current using the viewer's bindNormalContext() method and released using the viewer's unbindNormalContext() method. This context can also be queried using the viewer's getNormalSoContext() method.
If you do not have (or do not have access to) a viewer, you can create a context by creating an OIV.Inventor.Devices.SoGLContext object. In almost all cases, calling the constructor with a true value will create a context that is in a share group with the rendering context. In other words, resources such as textures and buffer objects are shared between these contexts and can be used in any of the contexts in the share group. For example:
SoGLContext glContext = new SoGLContext(true); glContext.Bind(); SoGpuBufferObject gpuBuffer = new SoGpuBufferObject( SoGpuBufferObject.BufferAccessFrequencies.STATIC, SoGpuBufferObject.BufferAccessNatures.SHARED ); glContext.Unbind();
SoGLContext context = SoGLContext.GetCurrent( true ); if (context != null) context.SetNoGLContextDelete(); // Context is managed by someone else else context = new SoGLContext( true ); context.Bind(); . . . context.Unbind();