[osg-users] Updating VBO's during runtime

Robert Osfield robert.osfield at gmail.com
Fri Jun 1 07:37:59 PDT 2018


Hi Brad,

In principle calling array->dirty(); should be enough to get the data
to update, though the underlying code has seen a lot of changes
between 3.4 and 3.6.  Which version of the OSG are you using?

When setting up the arrays you need either specify the binding on the
osg::Array, or pass the binding in with the set*Array(array, binding)
call.

If the problem presists when using OSG-3.6.1 could you create a
compilable example program so we can test it and see the problem first
hand, if there is bug in the OSG we'll need to track it down and fix
it, if it's a problem in your code then we'll also be able to spot
this and recommend how you can do things better.

Cheers,
Robert.


On 1 June 2018 at 15:20, Brad Colbert <bcolbert at rscusa.com> wrote:
> I'm updating my vertices at runtime.  I've found a few posts that discuss
> this:
>
> (a couple are:)
> http://forum.openscenegraph.org/viewtopic.php?t=14826
> http://forum.openscenegraph.org/viewtopic.php?t=15782
>
> Let me first mention that I've compiled OSG with GL3 support, so no display
> lists.  That said, I'm still calling:
>
>   pointsGeom->setUseDisplayList(false);
>   pointsGeom->setUseVertexBufferObjects(true);
>
> Here is a snippet of my call to update the vertices (v_ = vertices, c_ =
> colors, n_ = normals, da_ = DrawArrays, g_ = Geometry):
>
>     for (int i = 0; i < numVertices; i++) {
>       // Verticies
>       v_.at(i)[0] = 500.f * (0.0f + (3.0f * float(rand() % 1000) / 1000.f) -
> 1.5f);
>       v_.at(i)[1] = 500.f * (0.0f + (4.0f * float(rand() % 1000) / 1000.f) -
> 2.f);
>       v_.at(i)[2] = 500.f * (1.5f + (0.1f * float(rand() % 1000) / 1000.f) -
> 0.05f);
>
>       // Colors
>       c_.at(i)[0] = 1.f;
>       c_.at(i)[1] = 1.f;
>       c_.at(i)[2] = 1.f;
>       c_.at(i)[3] = 1.f;
>
>       // Normals
>       n_.at(i)[0] = 0.f;
>       n_.at(i)[1] = 1.f;
>       n_.at(i)[2] = 0.f;
>     }
>
>     v_.dirty();
>     c_.dirty();
>     n_.dirty();
>
>     da_.setCount(numVertices);
>     da_.dirty();
>
>     // *** The dirty() calls above are supposed to tell OSG to update the
> VBO's.  For
>     // some reason this isn't happening.  We are going to force it here.
> Not sure of the
>     // performance implications but hopefully this is temporary.
>     g_.setVertexArray(&v_);
>     g_.setColorArray(&c_);
>     g_.setNormalArray(&n_);
>
>     g_.dirtyBound();
>
> The update just doesn't happen unless I call the setVertexArray,
> setColorArray, setNormalArray methods which doesn't match what the previous
> posts about this topic.
>
> Is this because of GL3 or something else?
>
> Thanks,
> Brad
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list