Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: updating VOB data!

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    161

    updating VOB data!

    hi all!

    Im using VOB and Im doing vertex animation... the animation is not working unless I rebind the vertex data using glBufferSubData... I wondering what is the commun way to tell the vob that the data has changed? do I even need to?

    thx

  2. #2
    Intern Newbie
    Join Date
    Sep 2007
    Posts
    45

    Re: updating VOB data!

    Yes, you have to, you uploaded buffer to gpu and lost the pointers.
    glMapBufferARB/glUnMapBufferARB maybe?

    And it is VBO!

  3. #3
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    161

    Re: updating VOB data!

    ya you r right its VBO... now.. here is the version where I think it should work but the vertices are not updated when animated:

    Code :
    void OpenGL::SetClientBuffer(Primitive *in_primitive)
    {
    	UInt &l_buffer = in_primitive->GetBufferArray();
    	if (l_buffer == 0)
    	{
    		glGenBuffers(1, &l_buffer);
    		glBindBuffer(GL_ARRAY_BUFFER, l_buffer);
    		glBufferData(GL_ARRAY_BUFFER, in_primitive->GetBufferArraySize(), NULL, in_primitive->GetBufferType());
    		glBufferSubData(GL_ARRAY_BUFFER, in_primitive->GetVertices().GetBufferOffset(), in_primitive->GetVertices().GetBufferSize(), in_primitive->GetVertices().GetData());
     
    	else
    		glBindBuffer(GL_ARRAY_BUFFER, l_buffer);
    }

    and here is the version where the vertices are being updated:

    Code :
    void OpenGL::SetClientBuffer(Primitive *in_primitive)
    {
    	UInt &l_buffer = in_primitive->GetBufferArray();
    	if (l_buffer == 0)
    	{
    		glGenBuffers(1, &l_buffer);
    		glBindBuffer(GL_ARRAY_BUFFER, l_buffer);
    		glBufferData(GL_ARRAY_BUFFER, in_primitive->GetBufferArraySize(), NULL, in_primitive->GetBufferType());
    		glBufferSubData(GL_ARRAY_BUFFER, in_primitive->GetVertices().GetBufferOffset(), in_primitive->GetVertices().GetBufferSize(), in_primitive->GetVertices().GetData());
     
    	else
    	{
    		glBindBuffer(GL_ARRAY_BUFFER, l_buffer);
    		glBufferSubData(GL_ARRAY_BUFFER, in_primitive->GetVertices().GetBufferOffset(), in_primitive->GetVertices().GetBufferSize(), in_primitive->GetVertices().GetData());
    	}
    }

    is this the way to go?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: updating VOB data!

    I think you misunderstood how the VBOs work. When you call glBufferSubData, the pointed data are copied into VBOs memory. They will be not influenced by any change to the content of the original array they were copied from. You need to explicitly copy new data to the buffer by use of glBufferSubData or the glMapBufferARB api if you need them to change.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    161

    Re: updating VOB data!

    You need to explicitly copy new data to the buffer
    I see, in that case, is the use of vbo still worth it for vertex animation instead of standard client states?

    my understanding of using the buffer type set to dynamic would have reset the data automaticly...

    thx

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: updating VOB data!

    Quote Originally Posted by Golgoth
    I see, in that case, is the use of vbo still worth it for vertex animation instead of standard client states?
    It depends on how many times you will draw that geometry per one upload and how the driver handles memory management for draws issued using standard client arrays. You can try to compare the performance for your specific case.

    my understanding of using the buffer type set to dynamic would have reset the data automaticly...
    No. That only tells the driver that the buffer is expected to be updated often.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •