Click or drag to resize
SoGLContext Class

OpenGL context management class.

Inheritance Hierarchy

Namespace: OIV.Inventor.Devices
Assembly: OIV.Inventor.GL (in OIV.Inventor.GL.dll) Version: 2024.1.1.0 (2024.1.1)
public class SoGLContext : SoDeviceContext

The SoGLContext type exposes the following members.

Public methodSoGLContext(Boolean)

Constructor which creates an OIV.Inventor.Devices.SoGLContext based on the attributes of the current context.

Public methodSoGLContext(SoGLContext, Boolean)

Constructor which creates an OIV.Inventor.Devices.SoGLContext based on the attributes of the specified context.

Public methodAssertContext

Assert this context and the current active context are the same.

Public methodBind

Bind this context to the current thread.

(Inherited from SoDeviceContext.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodStatic memberGetContextFromId

Returns the context corresponding to an internal id.

Public methodStatic memberGetContextFromSharedId

Returns the first context that belongs to the specified sharedIdGroup.

Public methodGetContextGraphicsCapabilities

Retrieve graphics capabilities from this context.

Public methodStatic memberGetCurrent
Calls GetCurrent(false).
Public methodStatic memberGetCurrent(Boolean)

Returns the current active OpenGL context (if any).

Public methodGetFormat

Returns the OIV.Inventor.Devices.SoGLFormat associated to the OIV.Inventor.Devices.SoGLContext.

Public methodStatic memberGetGraphicsCapabilities

Retrieve graphics capabilities from the current bound context, if any.

Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetId

Returns the internal id for this context.

Public methodGetSharedGroup

Returns the current shared group.

(Inherited from SoDeviceContext.)
Public methodStatic memberGetSharedGroupPolicy

Returns the current sharedGroupPolicy.

Public methodGetSharedId

Returns an id common to all compatible/shared contexts.

(Inherited from SoDeviceContext.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInvalidate

Set this context as invalid so it won't be used anymore.

Public methodIsCompatible

Returns true if two contexts are compatible.

(Inherited from SoDeviceContext.)
Public methodIsCurrent

Returns true if the context is valid and currently active.

(Inherited from SoDeviceContext.)
Public methodIsSharable

Returns the sharable status of this context.

(Inherited from SoDeviceContext.)
Public methodIsSharedWith

Returns the current sharing state with passed context.

(Inherited from SoDeviceContext.)
Public methodIsValid

Returns true if this context is valid.

(Inherited from SoDeviceContext.)
Public methodIsValidForCurrent

Returns true if the context is the current active context or if it is shared with the current active context.

Public methodSetNoGLContextDelete

Prevent deletion of the native OpenGL context by OIV.Inventor.Devices.SoGLContext.

Public methodSetSharable

Sets the sharable property.

(Inherited from SoDeviceContext.)
Public methodSetSharedGroup

Explicitly change the sharedGroup.

(Inherited from SoDeviceContext.)
Public methodSetSharedWith

Share this context.

(Inherited from SoDeviceContext.)
Public methodSwapBuffers

Swaps the buffers with the value stored in the OIV.Inventor.Devices.SoGLFormat, which is set to the main plane by default.

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryBind

Try to bind the OpenGL context to the current thread.

Public methodUnbind

Unbind this context from the current thread.

(Inherited from SoDeviceContext.)
Public propertyIsDisposable
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.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);
   SoGpuBufferObject gpuBuffer = new SoGpuBufferObject( SoGpuBufferObject.BufferAccessFrequencies.STATIC, SoGpuBufferObject.BufferAccessNatures.SHARED );

If the OpenGL context is created and managed by the application or a third- party library, the application should create an OIV.Inventor.Devices.SoGLContext object to wrap the actual current context, then () and () this object around the Open Inventor render call. Note that this method will return null if there is no current OpenGL context. Also note that the OIV.Inventor.Devices.SoGLContext object should be told not to manage (specifically not to delete) the OpenGL context since its lifespan is managed by other software. For example:

SoGLContext context = SoGLContext.GetCurrent( true );
if (context != null)
   context.SetNoGLContextDelete(); // Context is managed by someone else
   context = new SoGLContext( true );
   . . .


See Also