<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Brad,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Check to make sure your Geometry has setDataVariance(osg::Object::DYNAMIC). That solved the problem for most of our similar cases.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- Dan<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> osg-users [mailto:osg-users-bounces@lists.openscenegraph.org]
<b>On Behalf Of </b>Brad Colbert<br>
<b>Sent:</b> Friday, June 01, 2018 10:20 AM<br>
<b>To:</b> osg-users@lists.openscenegraph.org<br>
<b>Subject:</b> [osg-users] Updating VBO's during runtime<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">I'm updating my vertices at runtime. I've found a few posts that discuss this:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(a couple are:)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://forum.openscenegraph.org/viewtopic.php?t=14826">http://forum.openscenegraph.org/viewtopic.php?t=14826</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://forum.openscenegraph.org/viewtopic.php?t=15782">http://forum.openscenegraph.org/viewtopic.php?t=15782</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Let me first mention that I've compiled OSG with GL3 support, so no display lists. That said, I'm still calling:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> pointsGeom->setUseDisplayList(false); <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> pointsGeom->setUseVertexBufferObjects(true); <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here is a snippet of my call to update the vertices (v_ = vertices, c_ = colors, n_ = normals, da_ = DrawArrays, g_ = Geometry):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> for (int i = 0; i < numVertices; i++) {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> // Verticies<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> v_.at(i)[0] = 500.f * (0.0f + (3.0f * float(rand() % 1000) / 1000.f) - 1.5f);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> v_.at(i)[1] = 500.f * (0.0f + (4.0f * float(rand() % 1000) / 1000.f) - 2.f);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> v_.at(i)[2] = 500.f * (1.5f + (0.1f * float(rand() % 1000) / 1000.f) - 0.05f);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> // Colors<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> c_.at(i)[0] = 1.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> c_.at(i)[1] = 1.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> c_.at(i)[2] = 1.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> c_.at(i)[3] = 1.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> // Normals<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> n_.at(i)[0] = 0.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> n_.at(i)[1] = 1.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> n_.at(i)[2] = 0.f;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> v_.dirty();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> c_.dirty();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> n_.dirty();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> da_.setCount(numVertices);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> da_.dirty();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><b> // *** The dirty() calls above are supposed to tell OSG to update the VBO's. For</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b> // some reason this isn't happening. We are going to force it here. Not sure of the</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b> // performance implications but hopefully this is temporary.</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b> g_.setVertexArray(&v_);</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b> g_.setColorArray(&c_);</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b> g_.setNormalArray(&n_);</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> g_.dirtyBound();<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The update just doesn't happen unless I call the <b><span style="font-family:"Arial","sans-serif";color:#222222;background:white">setVertexArray</span></b>,
<b><span style="font-family:"Arial","sans-serif";color:#222222;background:white">setColorArray</span></b>,
<b><span style="font-family:"Arial","sans-serif";color:#222222;background:white">setNormalArray</span></b> methods which doesn't match what the previous posts about this topic.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is this because of GL3 or something else?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Brad<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>