[osg-users] shared VertexBufferObject question

Pecoraro, Alexander N alexander.n.pecoraro at lmco.com
Mon Sep 22 11:53:29 PDT 2008


I did some reading about VBOs on the NVidia developer site and it turns
out that the glBindBuffer() call is not the one that I should worry
about. The white paper I read said that limiting the number of calls to
glVertexPointer() was the proper way to optimize the use of VBOs.

So I noticed that there was some commented out code in include/State
that appeared to be for the purpose of preventing redundant calls to
glVertexPointer() - see below:

inline void setVertexPointer( GLint size, GLenum type,
                                      GLsizei stride, const GLvoid *ptr
)
{
  .... (only showing relevant parts of code)
  //if (_vertexArray._pointer!=ptr || _vertexArray._dirty)
  {
    _vertexArray._pointer=ptr;
    glVertexPointer( size, type, stride, ptr );
  }
  _vertexArray._dirty = false;
}

Seems like if the commented out IF statement was not commented out then
I could have multiple Geometry nodes share a vertex buffer object and a
vertex array and only require one call to glVertexPointer(). Wouldn't
that be more efficient?

Alex

-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: Saturday, September 20, 2008 1:56 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] shared VertexBufferObject question

Hi Alex,

The unbind is done to prevent state leakage.  One could potentially
using lazy state updating on VBO state by placing more controls into
osg::State, but this would require all Drawables to be careful about
what they assume is current state.  It's possible but it's quite a bit
of work.

Robert.

On Sat, Sep 20, 2008 at 12:42 AM, Pecoraro, Alexander N
<alexander.n.pecoraro at lmco.com> wrote:
> I want to create a VertexBufferObject that is shared by several
Geometry
> nodes so that the number of calls to glBindBuffer() are decreased, but
I
> noticed that on lines 1561 - 1567 of Geometry.cpp there is some code
that
> automatically unbinds the vertex buffer object effectively forcing
each
> Geometry node to rebind the VBO each time. Why does it do this? Isn't
this
> preventing a shared VBO from being used in the most efficient way
possible?
>
>
>
> Thanks.
>
>
>
> Alex
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
>
>
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



More information about the osg-users mailing list