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 3 of 3

Thread: Change VBO offset while drawing instances

  1. #1
    Intern Newbie
    Join Date
    Oct 2011
    Posts
    47

    Change VBO offset while drawing instances

    I want to do something like instanced rendering ...but sort of the opposite. With vertexAttribDivisor I can set something like "after every 5 instances it jumps to the next index in the VBO". But what I need is like "after every instance it jumps 5 indices in the VBO".

    The only thing I can think of right now is that after every instance I change the buffer offset in the VBO with vertexAttribPointer, ...but I dont want to do that state change that often.
    Any ideas? Thanks!

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by Aliii View Post
    I want to do something like instanced rendering ...but sort of the opposite. With vertexAttribDivisor I can set something like "after every 5 instances it jumps to the next index in the VBO". But what I need is like "after every instance it jumps 5 indices in the VBO".
    Unless you've omitted something in your description, you just need to use the appropriate value for the stride parameter in the glVertexAttribPointer() call.

  3. #3
    Intern Newbie
    Join Date
    Oct 2011
    Posts
    47
    Quote Originally Posted by GClements View Post
    Unless you've omitted something in your description, you just need to use the appropriate value for the stride parameter in the glVertexAttribPointer() call.
    I mean ...skip indices logically ...not skip them physically in the memory. Thats what stride does.

    To give an example:
    I have 2 VBOs. In one there are the positions of the vertices, in the other one there are the colors. But the second one has twice as many elements in it, because I want to draw the same object twice ...but with different colors. So I draw 2 instances of the object, and after the first instance I want to skip the colors of the first object and use the colors of the second object.

    ...and without changing VBO-s, or calling vertexAttribPointer to change the offset.

Posting Permissions

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