Hi,
While trying to debug a collegue's code that uses a dynamically updated
color array on a Geometry that uses VBOs I'm getting confused about VBO
support in OSG 2.8.
Given the attached simple .osg file (a single colored quad, flagged to
not use display lists, but to use VBOs) I can see with an OpenGL tracer
(bugle) that no VBO is actually used on my nvidia FX5200 system. The
quad is simply drawn using glVertex() and friends. Are there limitations
to when VBOs can be used? And, if so, is there a way to have OSG loudly
complain when a request for VBOs can not be satisfied?
Similarly, the attached c++ test case is more in line with our original
code. It uses a color array that is updated each frame. The array is
flagged as dirty with a call to dirty(), but here also, no VBOs seem to
get used.
Regards,
Paul
PS glxinfo reports GL_ARB_vertex_buffer_object is supported, OpenGL
version is 2.1.0 NVIDIA 96.43.01
Geode {
nodeMask 0xffffffff
cullingActive TRUE
num_drawables 1
Geometry {
useDisplayList FALSE
useVertexBufferObjects TRUE
PrimitiveSets 1
{
DrawArrays QUADS 0 4
}
VertexArray Vec3Array 4
{
0 0 0
0 1 0
1 1 0
1 0 0
}
NormalBinding PER_PRIMITIVE
NormalArray Vec3Array 1
{
0 0 1
}
ColorBinding PER_VERTEX
ColorArray Vec4Array 4
{
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
}
}
}
// g++ -o vbo vbo.cpp -I ~/osg2.8/include/ -L ~/osg2.8/lib -losg -losgViewer
#include <osg/Geometry>
#include <osg/Array>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
int main()
{
osg::Vec3Array *verts = new osg::Vec3Array;
verts->push_back(osg::Vec3(0, 0, 0));
verts->push_back(osg::Vec3(0, 0, 1));
verts->push_back(osg::Vec3(1, 0, 1));
verts->push_back(osg::Vec3(1, 0, 0));
osg::Vec4Array *colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1,0,0,1));
colors->push_back(osg::Vec4(1,0,0,1));
colors->push_back(osg::Vec4(1,0,0,1));
colors->push_back(osg::Vec4(1,0,0,1));
osg::Vec3Array *normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0, -1, 0));
osg::Geometry *geom = new osg::Geometry;
geom->setVertexArray(verts);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));
geom->setUseVertexBufferObjects(true);
geom->setUseDisplayList(false);
geom->setDataVariance(osg::Object::DYNAMIC);
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
osgViewer::Viewer viewer;
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
viewer.setSceneData(geode);
viewer.realize();
int frame = 0;
while (!viewer.done())
{
viewer.frame();
colors->at(0) = osg::Vec4(0,(frame%250)/250.0,0,1);
colors->at(1) = osg::Vec4(0,(frame%250)/250.0,0,1);
colors->at(2) = osg::Vec4(0,(frame%250)/250.0,0,1);
colors->at(3) = osg::Vec4(0,(frame%250)/250.0,0,1);
colors->dirty();
//geom->setColorArray(colors);
frame++;
}
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org