LWJGL Forum

Programming => OpenGL => Topic started by: Tomm9080 on August 02, 2018, 12:16:25

Title: Index Buffer generation
Post by: Tomm9080 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?
Title: Re: Index Buffer generation
Post by: KaiHH 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.