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: dynamic geometry and VBOs

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2003
    Posts
    10

    dynamic geometry and VBOs

    Hi folks!
    Hello, I am getting crazy with VBO...so my problem is the following:

    My mesh is composed of 'n' triangle strips and these strips change in some cases in my application, so right now, I always upload the indices to my triangle strips in this way, in the display function:

    for i=0;i<n;i++ {
    ...
    glDrawElements GL_TRIANGLE_STRIP, size_strip[i], GL_UNSIGNED_INT, this->vStrips[i] ;
    ...
    }

    But I think my perfomance will improve if I only upload the strips that change, and not every strip every time.

    How can I do this?

    Thanks in advance.
    F.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    748

    Re: dynamic geometry and VBOs

    Pardon my ignorance but what does the code sample you supplied have to do with VBO? Your calling DrawElements() and passing it a pointer to your array of Indices.

    A VBO call is more like...

    Code :
    glBindBufferARB ( GL_ELEMENT_ARRAY_BUFFER_ARB, VBO_IndicesBufferID );
    glDrawElements ( GL_TRIANGLE_STRIP, size_strip[i], GL_UNSIGNED_SHORT, BUFFER_OFFSET(0) );
    To update the VBO Indices you bind the buffer, then map the buffer, then upload the new indices. If you don't want to do this every frame, then you don't. If you only want to do the strips that have changed, then you only do those strips...

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: dynamic geometry and VBOs

    If strips use the same modelview matrix and material (i e, you can DrawElements() right after each other without changing state) then you're likely to get better performance from using a triangle list rather than a triangle strip. The reason is that the per-call overhead to start a new primitive is pretty hefty, whereas a vertex cache hit (very common in triangle lists) is almost free (except for the extra 4 bytes across the bus).

    That being said, DrawElements() isn't the best way to submit geometry. DrawRangeElements() is an improvements, for starters. After that, actually using VBO will probably add additional helpage.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  4. #4
    Member Regular Contributor
    Join Date
    May 2000
    Location
    London, UK
    Posts
    490

    Re: dynamic geometry and VBOs

    Originally posted by jwatte:
    If strips use the same modelview matrix and material (i e, you can DrawElements() right after each other without changing state) then you're likely to get better performance from using a triangle list rather than a triangle strip. The reason is that the per-call overhead to start a new primitive is pretty hefty, whereas a vertex cache hit (very common in triangle lists) is almost free (except for the extra 4 bytes across the bus).
    I found the fastest method in that situation was to pass the indexes through NVTriStrip, setting the primitive restart flag (if available) and making a single triangle strip draw call using VAR/VBO. There was a big difference in performance in my app compared with using triangle lists.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2003
    Posts
    10

    Re: dynamic geometry and VBOs

    Thanks for your responses...I think I have not explained very well my problem.

    Take a look my little code please:

    Code :
    ------------------------------------------------------
    // .1. only once at inicilization
     
    //variable declaration
    GLuint vertex_buf;
    int size = TOTALVERTS * 3 * sizeof(float);
    float *vertices=new float[TOTALVERTS*3];
     
     
    glGenBuffersARB(1, &amp;vertex_buf);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
     
    //Fill vertices
    ...
     
    //upload data
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, vertices, GL_STATIC_DRAW_ARB); 
     
    delete [] vertices;
     
    // uses ARB_VBO
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
    glVertexPointer(3, GL_FLOAT, 0,0);
    // activate vertex array
    glEnableClientState(GL_VERTEX_ARRAY);
     
    ---------------------------------------------------------
    // .2. Render Loop
     
    for (i=0;i<TOTALSTRIPS;i++) {
    ...
    glDrawElements(GL_TRIANGLE_STRIP, size_strip[i], GL_UNSIGNED_INT, this->vStrips[i]) ;
    ...
    }
    So I use VBO only with my vertices, which are static data, but, on the other side, strips are changing as long as the applicaction change the level of detail, thus, the indices are dynamic, but I dont know how to implement it with VBO , right now I always upload every index of every strip with DrawElements.
    My intention is to draw every strip, but only upload those which change. (I already have some 'dirty' flags to know which strips change between lod)

    Could you help me please.

    thanks in advance.F.

  6. #6
    Intern Newbie
    Join Date
    Jul 2004
    Posts
    49

    Re: dynamic geometry and VBOs

    Do you want to store your indices in a VBO? The spec has examples of how to do this. Take a look at the parts about GL_ELEMENT_ARRAY_BUFFER_ARB.

Posting Permissions

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