Class SoGLCallback
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
public class SoGLCallback extends SoCallback
Provides custom OpenGL behavior during rendering actions. This node behaves exactly like anSoCallbackexcept... theSoGLCallbacknode allows the application to make OpenGL calls during a render traversal. It is normally used to make OpenGL rendering calls (and any state setting calls needed for rendering).SoGLCallbackautomatically calls glPushAttrib() to save the OpenGL state before executing the callback and then calls glPopAttrib() (restore) after executing the callback, ensuring that OpenGL state cannot leak outside the node.Please note that this means an
SoGLCallbacknode cannot modify the OpenGL state used for Open Inventor rendering. (This is a change since Open Inventor 10.0) You must use standard Open Inventor nodes to modify state for Open Inventor rendering. For example, use anSoViewportnode to change the OpenGL viewport, use theSoDepthBuffernode to change the OpenGL depth buffer test and so on.You can use this node to get values from the Open Inventor traversal state list using the
SoElementclasses. For example,SoLineWidthElementcontains the current line width set by anSoDrawStylenode.This node should not be used to do Open Inventor rendering. Open Inventor rendering calls should only be done using an SoCallBack node.
There is some "overhead" for rendering using
SoGLCallbackinstead of Open Inventor nodes. Normal Open Inventor rendering is optimized in various ways to maximize GPU performance and to keep the GPU "busy". When anSoGLCallbacknode is traversed, Open Inventor must finish all current rendering, execute the application's OpenGL calls, then resume normal rendering.Create the node:
Create the Callback: The callback function registered with the node will only be executed duringSoGLCallback glCallbackNode = new SoGLCallback(); glCallbackNode.setGLCallback( new myGLCallback() ); root.addChild( glCallbackNode ); SoGLRenderActiontraversal, as calling OpenGL functions requires a current OpenGL context.
Or create node and callback in-line:class myCallback implements SoCallback.CB { @Override public void invoke( SoAction action ) { // Safe to call OpenGL functions } }
File format/default:SoCallback callbackNode = new SoCallback(); callbackNode.setCallback( new SoCallback.CB() { @Override public void invoke( SoAction action ) { // Safe to call OpenGL functions } } ); GLCallback {
Action behavior:
SoGLRenderAction,SoGetBoundingBoxAction,SoPickAction
Calls the specified callback for all actions.- Since:
- Open Inventor 10.0
- See Also:
SoAction,SoCallback,SoCallbackAction,SoEventCallback
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoCallback
SoCallback.CB
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoGLCallback()Constructor.
-
Method Summary
-
Methods inherited from class com.openinventor.inventor.nodes.SoCallback
setCallback
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-