VR-Forces 4.1 Class Documentation
8.5 - Making OpenGL Calls from OSG Drawables

It is possible to call OpenGL directly from an OSG drawable.

It is very easy to corrupt the scene rendering when you do this. OSG maintains a copy of the OpenGL state in its own state object osg::State. If this state object and the actual OpenGL state are not synchronized, then the rendering will not be correct. If you must call OpenGL directly, you must undo any changes to the OpenGL state that you make. After your code is executed, the OpenGL state must be returned to the values it had before your code was executed. This will ensure that the OSG and OpenGL states are synchronized.

The following pseudo-code is an example of what must happen for all OpenGL states:

//For all states you want, check the existing OSG state.
If(osg_state != desired_state)
{
OPENGL_setState(desired_state);
}
//Call render commands
OPENGL_renderCommands();
//For all states you changed, restore back to the OSG state.
If(osg_state != desired_state)
{
OPENGL_setState(osg_state);
}

[<< Cockpit Display Updaters] [Home]


Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)