Hi Fred,

You interpretation of what Geometry::setUseVertexBufferObjects(true)
is correct, so what you are see looks to be a bug.  Which version of
the OSG are your using?

A couple of weeks ago I was looking into VBO setup issues relating to
the new serializers and tracked down the issues I was seeing to
src/osg/Geometry.cpp, so I then tidied up the loopholes in the set up
of the VBO's.  The problems I saw was that is some usage models the
VBO's were all setup correctly, but others it wasn't, so I closed
these loopholes, these fixes are now checked into svn/trunk.

There might still be some combinations of usage that I didn't spot, if
svn/trunk has them then just point me in the right direction.

Robert.

On Tue, Nov 23, 2010 at 3:41 PM, Fred Smith <[email protected]> wrote:
> 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
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to