Re: [osg-users] glPushAttrib(GL_ALL_ATTRIB_BITS) vs. pushStateSet(), apply(), popStateSet()

2008-02-20 Thread Robert Osfield
Hi Brett,

State::pushStateSet()/popStateSet() is not equivilant to
glPushAttrib/glPopAttrib() son't can't be used in place.  There are
several haveApplied*() methods in osg::State that can be used to pass
declare certain state dirty, and this is the most efficient way to do
things, but... it does require you to know what state has been
applied, and if its a black box then you won't know and
glPushAttribute/glPopAttrib() will have to be used, and most probably
the client state will need to be pushed and popped as well.

Robert.

On Feb 20, 2008 7:22 PM, Brett Wiesner [EMAIL PROTECTED] wrote:
 Hi,

 I have a custom drawable that makes calls to some openGL code in the
 drawImplementation() method (much like the osgTeapot example).

 The code is from a 3rd party vendor and they obviously make calls that
 change some openGL attributes because things like the stats handler stop
 working after this drawable is added to the scene.

 I've fixed the problem by pushing/ poping the openGL attributes like so:

 MyDrawable::drawImplementation( osg::RenderInfo ri) const
 {
glPushAttrib(GL_ALL_ATTRIB_BITS);

// do third party drawing code

glPopAttrib();
 }

 I have two questions. First, is there a way to use osg::state to do
 this? Would this work?

 MyDrawable::drawImplementation( osg::RenderInfo ri) const
 {
osg::state* state = ri.getState();
state-pushStateSet(getStateSet());

// do third party drawing code

state-popStateSet();
 }

 Second, if I could figure out what attributes the 3rd party code sets,
 would I be better off setting the stateSet of the drawable in the CTOR?

 Thanks,
 Brett
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] glPushAttrib(GL_ALL_ATTRIB_BITS) vs. pushStateSet(), apply(), popStateSet()

2008-02-20 Thread Brett Wiesner
Hi,

I have a custom drawable that makes calls to some openGL code in the 
drawImplementation() method (much like the osgTeapot example).

The code is from a 3rd party vendor and they obviously make calls that 
change some openGL attributes because things like the stats handler stop 
working after this drawable is added to the scene.

I've fixed the problem by pushing/ poping the openGL attributes like so:

MyDrawable::drawImplementation( osg::RenderInfo ri) const
{
   glPushAttrib(GL_ALL_ATTRIB_BITS);

   // do third party drawing code

   glPopAttrib();
}

I have two questions. First, is there a way to use osg::state to do 
this? Would this work?

MyDrawable::drawImplementation( osg::RenderInfo ri) const
{
   osg::state* state = ri.getState();
   state-pushStateSet(getStateSet());

   // do third party drawing code

   state-popStateSet();
}

Second, if I could figure out what attributes the 3rd party code sets, 
would I be better off setting the stateSet of the drawable in the CTOR?

Thanks,
Brett
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org