OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Updating VBO's during runtime


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
bcolbert (Brad Colbert)
User


Joined: 24 May 2012
Posts: 37

PostPosted: Fri Jun 01, 2018 2:20 pm    Post subject:
Updating VBO's during runtime
Reply with quote

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

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Fri Jun 01, 2018 2:38 pm    Post subject:
Updating VBO's during runtime
Reply with quote

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:
Quote:
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





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Daniel Emminizer, Code...
Guest





PostPosted: Fri Jun 01, 2018 2:40 pm    Post subject:
Updating VBO's during runtime
Reply with quote

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:] On Behalf Of Brad Colbert
Sent: Friday, June 01, 2018 10:20 AM
To:
Subject: 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(&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

------------------
Post generated by Mail2Forum
Back to top
bcolbert (Brad Colbert)
User


Joined: 24 May 2012
Posts: 37

PostPosted: Fri Jun 01, 2018 3:26 pm    Post subject:
Updating VBO's during runtime
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

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: (
Only registered users can see emails on this board!
Get registred or enter the forums!
)] On Behalf Of Brad Colbert
Sent: Friday, June 01, 2018 10:20 AM
To: (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Subject: 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(&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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Fri Jun 01, 2018 3:47 pm    Post subject:
Updating VBO's during runtime
Reply with quote

Hi Brad,

On 1 June 2018 at 16:26, Brad Colbert <> wrote:
Quote:
Hah! Daniel, that was it. Darnit!

Good to hear it's fixed.

Quote:
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.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Updating scene properties instead of ... OmegaDoom General 6 Mon Jul 02, 2018 5:34 am View latest post
No new posts Adding primitiveset in runtime sergio2k18 General 7 Tue May 01, 2018 9:12 pm View latest post
No new posts [A standardized way to mod scene grap... mp3butcher General 2 Wed Feb 07, 2018 6:16 pm View latest post
No new posts Call for assistance: Migrating and up... Chris Hanson General 15 Mon Oct 09, 2017 4:07 pm View latest post
No new posts Significant drop in frame rate when u... wernerM General 5 Mon Mar 20, 2017 3:32 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP