I see. Apologies for the misinformation.
WL
--------------------------------------------------
From: "PCJohn" <[email protected]>
Sent: Wednesday, August 04, 2010 9:33 AM
To: "OpenSceneGraph Users" <[email protected]>
Subject: Re: [osg-users] threading and captureCurrentState
Hi,
captureCurrentState name is misleading - it is not capturing state from
OpenGL.
It should be, maybe, getCurrentState. It is just taking last pushed
attributes on the state stack. These attributes are returned in the
StateSet given as parameter. Thus, the function should work any time
during cull traversal, I guess.
I do not understand, but it work with SingleThreaded and
CullDrawThreadPerContext while it crashes with DrawThreadPerContext and
CullThreadPerCameraDrawThreadPerContext. It seems to me like two threads
are accessing state stack...
John
Wojciech Lewandowski wrote:
Hi,
I don't think its allowed to call captureCurrentState in Cull stage. I am
not certain about this, but would expect that captureCurrentState would
read OpenGL state and update osg::State accordingly. If this is the case
then it does require valid OpenGL context, which is only guaranteed to be
valid in Render stage. SingleThreaded mode is bit different and manages
SceneViews differently which has the side effect that OpenGL context
often remains valid beetwen Render stages .
Wojtek
--------------------------------------------------
From: "PCJohn" <[email protected]>
Sent: Tuesday, August 03, 2010 4:38 PM
To: "OpenSceneGraph Users" <[email protected]>
Subject: [osg-users] threading and captureCurrentState
Hi,
I see a threading issue when capturing current attributes in cull phase.
My code placed in my derived ShadowTechnique::cull():
void MyShadowVolume::cull( osgUtil::CullVisitor& cv )
{
ref_ptr< StateSet > currentState = new StateSet;
cv.getState()->captureCurrentState( *currentState );
cv.pushStateSet( _ss1 );
_shadowedScene->Group::traverse( cv );
cv.popStateSet();
cv.pushStateSet( _ss2 );
_shadowedScene->Group::traverse( cv );
cv.popStateSet();
}
StateSets are not changing. It crashes inside captureCurrentState while
I have to wait few seconds. However, the time changes (race-condition?).
It looks like threading issue and if I set viewer.setThreadingModel(
SingleThreaded ), the problem seems to disappear.
Is the code above correct? Am I using captureCurrentState correctly? I
need it to determine FrontFace attribute settings.
Thanks,
John
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org