Time for action β the buildIndexBuffer() method
1. Add the
Index Buffer
region to theTerrain
class:#region Index Buffer private void BuildIndexBuffer(int width, int height) { int indexCount = (width-1) * (height-1) * 6; short[] indices = new short[indexCount]; int counter = 0; for (short z = 0; z < height - 1; z++) for (short x = 0; x < height - 1; x++) { short upperLeft = (short)(x + (z * width)); short upperRight = (short)(upperLeft + 1); short lowerLeft = (short)(upperLeft + width); short lowerRight = (short)(upperLeft + width + 1); indices[counter++] = upperLeft; indices[counter++] = lowerRight; indices[counter++] = lowerLeft; indices[counter++] = upperLeft; indices[counter++] = upperRight; indices[counter++] = lowerRight; } indexBuffer = new IndexBuffer( device, IndexElementSize.SixteenBits, ...