Re: [osg-users] Updating VBO's during runtime
Hi Brad, On 1 June 2018 at 16:26, Brad Colbert wrote: > Hah! Daniel, that was it. Darnit! Good to hear it's fixed. > BTW, I used to work at Code 5580. WAY back in the day. > > Thanks! > > Robert, sorry, I meant to mention version 3.6.0. Definitely recommend updating to 3.6.1. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Updating VBO's during runtime
Hah! Daniel, that was it. Darnit! BTW, I used to work at Code 5580. WAY back in the day. Thanks! Robert, sorry, I meant to mention version 3.6.0. Cheers, Brad On Fri, Jun 1, 2018 at 7:39 AM, Daniel Emminizer, Code 5773 < dan.emmini...@nrl.navy.mil> wrote: > Hi Brad, > > > > Check to make sure your Geometry has setDataVariance(osg::Object::DYNAMIC). > That solved the problem for most of our similar cases. > > > > - Dan > > > > > > *From:* osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] *On > Behalf Of *Brad Colbert > *Sent:* Friday, June 01, 2018 10:20 AM > *To:* osg-users@lists.openscenegraph.org > *Subject:* [osg-users] Updating VBO's during runtime > > > > 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(_);* > > *g_.setColorArray(_);* > > *g_.setNormalArray(_);* > > > > 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@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Updating VBO's during runtime
Hi Brad, Check to make sure your Geometry has setDataVariance(osg::Object::DYNAMIC). That solved the problem for most of our similar cases. - Dan From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Brad Colbert Sent: Friday, June 01, 2018 10:20 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Updating VBO's during runtime 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(_); g_.setColorArray(_); g_.setNormalArray(_); 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@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Updating VBO's during runtime
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 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(_); > g_.setColorArray(_); > g_.setNormalArray(_); > > 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@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Updating VBO's during runtime
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(_);* *g_.setColorArray(_);* *g_.setNormalArray(_);* 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@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org