Hello Guest

Index Buffer generation

  • 1 Replies
  • 516 Views
Index Buffer generation
« on: August 02, 2018, 12:16:25 »
Hi,

is there any possibility of generating a index-Buffer by calculating the exact order of values maybe  in an Array Maybe floats by a tool or sth like that,
or do i have to write it on my own in a method?

*

Offline KaiHH

  • ***
  • 161
Re: Index Buffer generation
« Reply #1 on: August 02, 2018, 16:18:21 »
Sure, given an ordered sequence of vertices having one of the available topologies/primitive types (such as GL_TRIANGLES) you can easily compute an index buffer which reuses duplicate/equal vertices.

For example, given the list (2D vertices for simplicity): [(0, 0), (1, 0), (1, 1), (1, 1), (0, 1), (0, 0)]
You can compute a new vertices list: [(0, 0), (1, 0), (1, 1), (0, 1)]
and a corresponding index buffer: [0, 1, 2, 2, 3, 0]

If that's what you're after.