Display callbacks can be inserted and any stage of the rendering loop. This allows you, for example to set up a p-buffer in the pre-begin frame slot, clear the buffers in the begin frame, render the scene to your p-buffer, etc.
![]()
|
Display callback and display pass plug-ins share the OpenGL state machine with Softimage. If a plug-in needs to change the OpenGL state, the plug-in should restore the original state when it is finished. |
The example in the following sections shows how a pass can clear the screen to a specific color.
Identifying the display callback to Softimage’s Plug-in Registrar
Custom display callbacks take advantage of Softimage’s self-installing plug-in manager, so the first thing to do is tell the plug-in registrar about what’s contained in the .dll or .so. This is done in the XSILoadPlugin function, as shown below.
XSI::CStatus XSILoadPlugin( XSI::PluginRegistrar& in_reg )
{
in_reg.PutAuthor( L"My Very Awesome Company inc." );
in_reg.PutName( L"Example Display Callbacks" );
in_reg.PutVersion( 1, 0 );
// Here we tell the Plugin Registrar that this DLL exports
// a display callback Called MyClearScreenBuffer
in_reg.RegisterDisplayCallback( L"MyClearScreenBuffer" );
}Injecting Display Callbacks into the Rendering Loop
After specifying the callback’s name, the plug-in manager will then look for five exported functions in.dll or .so.
void MyClearScreenBuffer_Init ( XSI::CRef, LPVOID * ); void MyClearScreenBuffer_Execute ( XSI::CRef, LPVOID * ); void MyClearScreenBuffer_Term ( XSI::CRef, LPVOID * ); void MyClearScreenBuffer_InitInstance ( XSI::CRef, LPVOID * ); void MyClearScreenBuffer_TermInstance ( XSI::CRef, LPVOID * );
Pay special attention to the _Init function, which tells Softimage all about your displays callbacks, such as where they fit into the sequence and which display mode it affects.
_InitInstance and _TermInstance get called each time a new viewport is created or destroyed.
Here’s an example of a callback that gets called after each BeginFrame event for each display mode (wireframe, Hidden line, etc.):
void MyClearScreenBuffer_Init ( XSI::CRef in_pSequencerContext, LPVOID *in_pUserData )
{
// Softimage's plug-in registrar calls this to initialize the display callback.
// Now, we must register the display callback with the Graphic Sequencer
// This simple example clears the frame buffer to custom color.
// The parameter XSI::siAll means that this callback affects all display
// modes, even custom ones
// Cast the CRef into a GraphicSequencerContext SDK object
XSI::GraphicSequencerContext l_vGraphicSequencerContext = in_pSequencerContext;
// Get the sequencer from the context object
XSI::CGraphicSequencer in_pSequencer = l_vGraphicSequencerContext.GetGraphicSequencer ();
// Use the sequencer to register the callback
in_pSequencer.RegisterDisplayCallback ( L"MyClearScreenBuffer", 0, XSI::siPostBeginFrame, XSI::siAll, NULL );
}Autodesk Softimage v7.5