Hi,
I wrote the following little node visitor to switch part of a scene graph
from using display lists to using VBOs.
class VBOVisitor : public osg::NodeVisitor
{
public:
VBOVisitor()
{
setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
}
virtual void apply(osg::Node& node)
{
osg::Geode *geode = node.asGeode();
if (geode != NULL)
{
for (unsigned int i = 0; i < geode->getNumDrawables(); i++)
{
osg::Drawable &drawable = *geode->getDrawable(i);
drawable.setUseDisplayList(false);
drawable.setUseVertexBufferObjects(true);
}
}
traverse(node);
}
};
I use it like this before attaching the object to the Viewer and rendering
it.
osg::Node *object = osgDB::readNodeFile("some_object.osg");
VBOVisitor vbo;
object->accept(vbo);
The OSG file in question contains a lot of Drawbles with the flags
useDisplayList TRUE
useVertexBufferObjects FALSE
This prevents advanced rendering techniques such as hardware instancing.
The idea was to use the VBOVisitor to get the same effect as if I had
changed these lines to
useDisplayList TRUE
useVertexBufferObjects FALSE
Editing the OSG file manually works, but using the VBOVisitor instead does
not produce the desired effect (i.e. hardware instancing fails)
What am I missing?
Christian
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org