public class SoGLContext extends SoDeviceContext
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 SoGLBufferObject
, bind() and unbind() an 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 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:
If the OpenGL context is created and managed by the application or a third- party library, the application should create an SoGLContext
object to wrap the actual current context, then bind() and unbind() 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 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:
Modifier and Type | Class and Description |
---|---|
static class |
SoGLContext.SharedGroupPolicies
Sharing Policy.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
AGGRESSIVE
Deprecated.
Use
SoGLContext.SharedGroupPolicies.AGGRESSIVE instead. |
static int |
CONSERVATIVE
Deprecated.
Use
SoGLContext.SharedGroupPolicies.CONSERVATIVE instead. |
static int |
DISABLED
Deprecated.
Use
SoGLContext.SharedGroupPolicies.DISABLED instead. |
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoGLContext(boolean shared)
Constructor which creates an
SoGLContext based on the attributes of the current context. |
SoGLContext(SoGLContext context,
boolean shared)
Constructor which creates an
SoGLContext based on the attributes of the specified context. |
Modifier and Type | Method and Description |
---|---|
void |
applySharedGroupPolicy()
Deprecated.
As of Open Inventor 9630 See documentation for more details
|
void |
assertContext()
Assert this context and the current active context are the same.
|
static SoGLContext |
getContextFromId(int id)
Returns the context corresponding to an internal id.
|
static SoGLContext |
getContextFromSharedId(int sharedIdGroup)
Returns the first context that belongs to the specified sharedIdGroup.
|
SbGPUCapabilities |
getContextGraphicsCapabilities()
Retrieve graphics capabilities from this context.
|
static SoGLContext |
getCurrent()
Calls getCurrent((boolean)false).
|
static SoGLContext |
getCurrent(boolean checkGLState)
Returns the current active OpenGL context (if any).
|
SoGLFormat |
getFormat()
Returns the
SoGLFormat associated to the SoGLContext . |
static SbGPUCapabilities |
getGraphicsCapabilities()
Retrieve graphics capabilities from the current bound context, if any.
|
int |
getId()
Returns the internal id for this context.
|
static SoGLContext.SharedGroupPolicies |
getSharedGroupPolicy()
Returns the current sharedGroupPolicy.
|
void |
invalidate()
Set this context as invalid so it won't be used anymore.
|
boolean |
isSharedWith(SoGLContext context)
Returns true if the specified context and this context are shared.
|
boolean |
isValid()
Returns true if this context is valid.
|
boolean |
isValidForCurrent()
Returns true if the context is the current active context or if it is shared with the current active context.
|
void |
setNoGLContextDelete()
Prevent deletion of the native OpenGL context by
SoGLContext . |
boolean |
swapBuffers()
Swaps the buffers with the value stored in the
SoGLFormat , which is set to the main plane by default. |
boolean |
swapBuffers(int plane)
Deprecated.
As of Open Inventor 9610 See documentation for more details
|
boolean |
tryBind()
Try to bind the OpenGL context to the current thread.
|
bind, dispose, getSharedGroup, getSharedId, isCompatible, isCurrent, isDisposable, isSharable, isSharedWith, setSharable, setSharedGroup, setSharedWith, unbind
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int DISABLED
SoGLContext.SharedGroupPolicies.DISABLED
instead.@Deprecated public static final int CONSERVATIVE
SoGLContext.SharedGroupPolicies.CONSERVATIVE
instead.@Deprecated public static final int AGGRESSIVE
SoGLContext.SharedGroupPolicies.AGGRESSIVE
instead.public SoGLContext(boolean shared)
SoGLContext
based on the attributes of the current context.
SoGLContext
will not be valid!
shared
- Indicates if we want to share the context. If true, context is shared with current context, depending on the currently defined SharedGroupPolicy. If false, context is explicitly not shared.public SoGLContext(SoGLContext context, boolean shared)
SoGLContext
based on the attributes of the specified context.
If
shared is true then the created OpenGL context will be shared with the given context, depending on the current SharedGroupPolicy.public static SoGLContext getCurrent()
@Deprecated public void applySharedGroupPolicy()
SoGLContext(SoGLContext.findSharedContext())
instead. public boolean isSharedWith(SoGLContext context)
public boolean tryBind()
public void setNoGLContextDelete()
SoGLContext
.
Note: Can be useful when the OpenGL context is created and managed by the application or a third-party library such as wxWidgets.
public SbGPUCapabilities getContextGraphicsCapabilities()
public static SoGLContext getCurrent(boolean checkGLState)
checkGLState
- If this parameter is true, the getCurrent()
function checks if the actual OpenGL context is the same as the one Open Inventor thinks is current. If the actual OpenGL context is different, for example because Open Inventor does not have a current context, then a new SoGLContext
object is created with the actual OpenGL context. This check is expensive if called many times.
public static SoGLContext.SharedGroupPolicies getSharedGroupPolicy()
public boolean isValidForCurrent()
public SoGLFormat getFormat()
SoGLFormat
associated to the SoGLContext
.
SoGLFormat
.public void assertContext()
public static SbGPUCapabilities getGraphicsCapabilities()
@Deprecated public boolean swapBuffers(int plane)
SoGLFormat
, which is set to the main plane by default. 0 If there is an overlay context and we want to swap the main plane 1 If there is an overlay context and we want to swap the overlay planeDeprecated since Open Inventor 9610 swapBuffers()
method without arguments instead. public int getId()
public void invalidate()
SoGLContext
has been created from an OpenGL context managed by the application or a third-party library (e.g.: Qt, JOGL...).public boolean isValid()
public boolean swapBuffers()
SoGLFormat
, which is set to the main plane by default.public static SoGLContext getContextFromSharedId(int sharedIdGroup)
sharedIdGroup
- The internal sharedIdGroup used to search for the context.
public static SoGLContext getContextFromId(int id)
id
- The internal id used to search for the context.
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com