On Jan 16, 2008 1:16 AM, Charles Han <[EMAIL PROTECTED]> wrote:
> What i have done so far is to create a myCameraPreDrawCallback which extends
> from Drawcallback. In this class i override the operator to create a
> GLObjectsVisitor. Also, when the callback is constructed i keep a reference
> to the sub graph and then in the call back operator i let the sub graph
> accepts the visitor.
>
> I am not sure this is a right approach but i am puzzled with one thing is
> how do you know the sub graph is complied and how to remove the call back?
You shouldn't need a reference to the subgraph, as the
DrawCallback::operator(..) takes the Camera that it's assigned to, and
the Camera contains the scene graph, and the Camera being just a Node.
In fact it takes less words in code...
struct CompileCallback : public osg::Camera::DrawCallback
{
virtual void operator() (const osg::Camera& camera)
{
osgUtil::GLObjectVisitor gov;
const_cast<osg::Camera&>(camera).accept(gov);
}
};
> Also, where should i get the camera from? is this just a camera i create or
> i should get from the viewer?
viewer.getCamera()->setDrawCallback(new CompileCallback);
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org