osgViewer doesn't expose SceneView, even though it uses it under the hood. So, if you have an osgViewer-based app, you need another way to get the contextID.
State has the contextID, so you should be able to getState()->getContextID() to get it. But who has State? Well, in many callbacks, you're passed a RenderInfo, and that has State, so you can do: renderInfo.getState()->getContextID() from most callbacks. However, in the recent thread you refer to, my code was in a Camera post-draw callback which doesn't get a RenderInfo as a parameter, it gets a Camera as a parameter. So, I get the contextID with the following: camera.getGraphicsContext()->getState()->getContextID(). This might look like a hack, as you said, but it isn't. But how should YOU get the contextID? >From your post, it sounds like you need to get the contextID from your Viewer. A Viewer could manage many contexts. It has the concept of a current context, but this is protected so you can't access it. However, you can get a std::vector of GraphicsContexts from your Viewer. See osgViewer::ViewerBase::getContexts(...). After you figure out which GraphicsContext you are interested in, you can call getState()->getContextID() on that GraphicsContext. I hope that helps. (It might also help if you said what you needed the contextID for? In my case, I needed it to get the Extensions object.) Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com 303 859 9466 > Hello, > I need to retrieve the current contextID or the contextID > that a Viewer is working on, how do I do it? > I saw in the documentation that one should retrieve the > SceneView but it doesn't say how / from where, and I couldn't > figure it out, as far a I could see osg::View and its > subclasses doesn't have such a getSceneView() method or > similar. I saw that there were some posts about how to > retrieve the context from a camera but that seemed to be more > of an hack than the actual "standard" way so if possible I > would like to avoid that solution. > So, what is the clean and mean way of retrieving the > SceneView given an osgViewer::Viewer? > > Regards, > Michele > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce negraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

