Hi,

The way I should be using Element Buffer Objects is unclear to me.
If I use the following code:


Code:
osg::Geometry* polyGeom = new osg::Geometry();
polyGeom->setUseVertexBufferObjects(true);

osg::ref_ptr<osg::DrawElementsUShort> de = new 
osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP,numIndices,myIndices);
polyGeom->addPrimitiveSet(de);



I expect the geometry to be using a VBO for vertex data *and* a VBO for index 
data. However it seems only a VBO for vertex data is used, eg. the following GL 
code is executed:

glBindBuffer(GL_ARRAY_BUFFER, &bufferid);
glBufferData(GL_ARRAY_BUFFER, ...);

glVertexPointer(3, GL_FLOAT, 0, offset_to_VBO);
glDrawElements(GL_TRIANGLE_STRIP, 4, ..., pointer_to_local_index_array);

No EBO is created then used in the last parameter in glDrawElements().

I am surprised this block of code above doesn't work as expected, as the 
Geometry.cpp file looks like this:


Code:
bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset)
{
    if (primitiveset)
    {
        if (_useVertexBufferObjects) 
addElementBufferObjectIfRequired(primitiveset);
[ ... ]




I also tried:

de->setElementBufferObject(new osg::ElementBufferObject());

but still no luck.

Furthermore, I checked the osgparametric sample and something else is 
disturbing me.

In this sample, when useVBO = true, createModel() calls 
geom->setUseVertexBufferObjects(true), but still manually sets up:

1) a VertexBufferObject, that it binds to the vertices
2) an ElementBufferObject, that it binds to the primitiveset

Isn't the call to geom->setUseVertexBufferObjects(true) sufficient? Isn't that 
the whole purpose of setUseVertexBufferObjects()?

I'm kind of confused here. Could somebody shed some light on this.

Thanks,
-F

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=33987#33987





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to