Robert, I've got a drawImplementation() method that gets the projection and 
modelview matrices and does something with them, pushes both matrices and sets 
up pixel coordinates (glOrtho in projection, glLoadIdentity in modelview), 
calls osg::Geometry::drawImplementation(), and then does the pops for both 
matrices.

Assume that I've got the OpenGL calls right (matrix mode, etc), since I haven't 
spelled them out and you don't have to debug that, and it seems pretty simple 
to me.  So I'm interested in what I might have to take into account regarding 
state left by OSG.

Could you give guidance about the sorts of things I'd have to do if there are 
vertex arrays still around?  You suggest checking the current vertex array 
state from osg::State, but I don't know what I'd actually need to do after I 
checked.  I could disable the vertex arrays, but I don't see anything for 
restoring that.

If there are a number of things that drawImplementation should check and 
handle, it may be that useful to have a routine we could call, since it seems 
it could be relevant in any drawImplementation.

The specific problem is some geometry (points) that doesn't appear when drawn 
after an object with my drawImplementation method.

I'm still running in 2.4.  Are there known fixes related to this in 2.6?

thanks,
andy


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield
Sent: Wednesday, August 27, 2008 11:30 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] OSG method for pushing/ popping entire openGL state 
machine?

Hi Brett,

There is no OSG call to push/pop the OpenGL state, if your own code
modifies the OpenGL state that you'll need to do the push/pop yourself
to make sure that the state is the same after as it was when entering
your code.  In your code example you are missing push/popping client
state so perhaps you should add this.

You'll also need to consider what state the OSG leaves OpenGL on
entering your code segment.  Assigning a StateSet to your custom
drawable is a good way of setting various OpenGL state you wish.  Also
make sure you are inheriting what state you require and not
inappropriate state down to your drawable.   Also be wary of the
vertex array settings that the OSG will have set OpenGL up as, the OSG
uses lazy state updating so won't change state that it doesn't need to
change, so it could be that some vertex arrays are left on on entering
your code.  You can check what the current vertex array state is from
osg::State's access methods - go browse through include/osg/State to
see the range of methods open to you.

Robert.

On Wed, Aug 27, 2008 at 3:37 PM, brettwiesner <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've got a third party product that does a bunch of openGL stuff inside the
> drawImplementation of a custom drawable. The third party stuff I use seems
> to leak state (it changes a bunch of indeterminable stuff in openGL) and
> that's causing weirdness with the rendering of the rest of my scene
> (textures turn blueish for example).
>
> I'd like to save the entire openGL state machine before the third party
> touches openGL, then restore it after. I'm doing the following but it's not
> quite working for me.
>
>     glPushAttrib(GL_ALL_ATTRIB_BITS);
>
>     .... do open gl stuff....
>
>    glPopAttrib();
> Is there an OSG call to make to do this? Perhaps other openGL calls?
>
> Thanks,
> Brett
>
> _______________________________________________
> 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

Reply via email to