Hi Paul,
Thanks for explanation, its now clear that State::reset() won't be
sufficient for the reason you explain, but also because State will
only know about OpenGL mode and osg::StateAttribute that are either
set up globally in SceneView or in the scene graph, modes and OpenGL
attributes not on this list won't be included at all.
The easist way would be to have the PEI VisKit OpenGL drawing code
enclosed within a glPushAttrib/glPopAttrib.
Next up would be to use the
osg::State::haveAppliedMode(),haveAppliedAttribute() methansim for
telling it that external code has changed the OpenGL state. For
instance for the GL_BLEND you'd do:
state->haveAppliedMode(GL_BLEND);
And then osg::State would know that that state is now dirty and must
be reapplied.
Robert.
On 7/31/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
My employer's application, FlightViz, is in a hybrid scene graph state
(half PEI VisKit and half OSG). To date, this has worked well with the
exception of state management. OSG doesn't know what state VisKit left
OpenGL in, and occasionally renders in the wrong state.
After rendering VisKit, and just before rendering OSG, I'd like a
mechanism to tell OSG "all bets are off, make no assumptions about how
state is currently set", but there is currently no way to do this.
I discussed this previously with Robert, who told me to try calling
State::reset() just before performing OSG rendering. However, I've ran
into some issues with this approach, and looking at the code, I'm not sure
how it would ever work.
Consider, for example, that VisKit has left GL_BLEND in its default
disabled state. Next, my code calls State::reset(), which contains the
following code:
for(ModeMap::iterator mitr=_modeMap.begin();
mitr!=_modeMap.end();
++mitr)
{
ModeStack& ms = mitr->second;
ms.valueVec.clear();
ms.last_applied_value = !ms.global_default_value;
ms.changed = true;
}
ms.global_default_value appears to be false for nearly everything, which
is correct for blending, and the above code appears, then, to set the
GL_BLEND mode's last_applied_value to true (NOT of false).
Imagine what happens next when my code renders an OSG subtree that tries
to enable blending. The corresponding ModeStack already thinks the
last_applied_value is true, so nothing happens when the state is applied,
and OSG renders my subtree with blending disabled.
I assume State::reset() is written that way for a reason, and I shouldn't
touch it. However, there needs to be some way for me to synchronize state
between an OSG State object and OpenGL, because they are clearly
out-of-sync in my usage. Seems like I have two options: 1) query the
last_applied_value for each mode in a State and explicitly set that in
OpenGL, or 2), the flip-side would be to add a ::sync() method to State
that would query OpenGL for each mode and set its last_applied_value
accordingly.
So, the least invasive method would be method 1, but I haven't seen an
intuitive way to iterate over all modes in a State to obtain their
last_applied_value. Has anyone tried this and found a way to do it that I
missed?
Thanks,
-Paul
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/