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 | (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.
Starting with Open Inventor 8.5, the application can control sharing of OpenGL contexts (previously this was done internally for rendering contexts). When OpenGL contexts are shared it means that display lists, texture objects, buffer objects, etc created in any context in that share group can be used by any other context in that group. This saves time and memory when rendering into multiple windows, buffers, etc.
In a typical Open Inventor application an OpenGL device context is created automatically by the viewer class and is managed automatically by the viewer for rendering and other operations involving the GPU. However this context is only made current when the viewer is actively using it, for example to render the scene graph. (Prior to Open Inventor 8.5, the viewer made its OpenGL context "current" and this context remained current even when the viewer was not actively rendering the scene graph. This was convenient in some cases, but could conflict with application strategies for managing OpenGL contexts.)
Do not assume that any OpenGL context is current. If you need a current OpenGL context, for example to create an OIV.Inventor.Devices.SoGLBufferObject, () 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(); SoGLBufferObject gpuBuffer = new SoGLBufferObject(SoGLBufferObject.Usages.STATIC_DRAW); gpuBuffer.SetTarget( SoGLBufferObject.BufferObjectTargets.ARRAY_BUFFER ); 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();