Hi,

I'm trying to find out a bit more about how to get OpenSceneGraph to
share an OpenGL context with another library... and to do that
properly i'd like to isolate both by saving and restoring state as
appropriate. I know this isn't the 'right' way to use OSG, and I know
that this kills performance, especially since OSG is designed to use
lazy state updating... but sometimes its a necessary evil. I'm
targeting OpenGL ES2.

Looking through some other posts, I've gathered:

You can get/save the current stateset by calling something like:
myViewer->getCamera()->getGraphicsContext()->getState()->captureCurrentState(myStateSet);

You can reset the current state by calling reset:
myViewer->getCamera()->getGraphicsContext()->getState()->reset();

You can apply a saved state by calling apply:
myViewer->getCamera()->getGraphicsContext()->getState()->apply(myStateSet);

But I'm not sure about a few things:

When should the osg::State be first saved? So basically, when is the
scene graph first traversed and the osg::State built up so that it's
appropriate for OSG to go ahead and render something? Does the initial
OpenGL state when OSG first builds up osg::State matter (I'm guessing
no)?

After saving this valid state, i'd do something like this to restore
it and render my scene...
// draw call
myViewer->getCamera()->getGraphicsContext()->getState()->reset();   //
is this line necessary?
myViewer->getCamera()->getGraphicsContext()->getState()->apply(myStateSet);
myViewer->frame();
// save state again if I modified the scene

Does that seem reasonable? Any advice/input would be appreciated.


Thanks

Preet
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to