The index buffer will contain That’s how we’ll link everything together. After all, the end of the first row is all the way on the right, and the beginning of the second row on the left. We don’t need to get fancy and start drawing right to left or anything like that.When we repeat the middle row of vertices, we only repeat the number, instead of repeating the entire block of data. We can instead use what’s known as a When drawing with GL_TRIANGLE_STRIP, Open GL will build triangles by taking each set of three vertices, advancing by one vertex for each triangle.Do you remember those graph calculators, that could draw parabolas and other stuff on the screen?In this example, we’re going to draw a 3d parabola using a height map.Here’s a visual illustration of the new vertex buffer: Notice that our vertices are no longer linked together into triangles.We’ll no longer pass our vertex buffer object directly; instead, we’ll use an index buffer to tie the vertices together.final float plane Vector X = ; final float plane Vector Y = ; final float normal Vector = ; // Normalize the normal final float length = Matrix.length(normal Vector, normal Vector, normal Vector); height Map Vertex Data[offset ] = normal Vector / length; height Map Vertex Data[offset ] = normal Vector / length; height Map Vertex Data[offset ] = normal Vector / length; Next up is the normal calculation.As you’ll remember from , the normal will be used to calculate lighting.
As our height map gets larger, our vertex buffer could end up having to repeat a lot of position, color, and normal data and consume a lot of additional memory. We’ll refer to these vertices using offsets into this vertex buffer, and when we need to reuse a vertex, we’ll repeat the offset instead of repeating the entire vertex.We need to repeat both the last vertex of the first row and the first of the second row. Let’s say we only repeated one vertex: Triangle 11 starts at the right and cuts all the way across to the left, which isn’t what we wanted to happen.The winding is now also incorrect for the next row of triangles, since 3 new triangles were inserted, swapping even and odd. I highly recommend heading over and reading before continuing.Every subsequent triangle shares two vertices with the previous triangle.For example, here are the sets of vertices that would be grouped into triangles: when building the triangles.Since each neighbour strip shares one row of vertices, we will end up repeating a lot of vertices with a vertex buffer.You can see a vertex buffer object containing the vertices for two triangle strip rows.We can use separate buffers for each attribute, such as positions and colors, or we can use a single buffer and interleave all of the data together.suggest interleaving the data and making sure it’s aligned to 4-byte boundaries for better performance.In this lesson, we’ll learn about index buffer objects, and go over a practical example of how to use them.Here’s what we’re going to cover: Let’s get started with the fundamental difference between vertex buffer objects and index buffer objects: In the previous lesson, we learned that a vertex buffer object is simply an array of vertex data which is directly rendered by Open GL.