void AddIndex( int i )

book_4_sparkGenerated
code_blocksInput

Description

The AddIndex method is used to add an index to the VertexBuffer. This method is essential when you are working with indexed drawing, where you define the order in which vertices are processed.

Usage

To use the AddIndex method, you need to have an instance of the VertexBuffer class. Call the method with an integer parameter that represents the index you want to add to the buffer.

Example

// Create a new VertexBuffer instance
VertexBuffer vertexBuffer = new VertexBuffer();

// Initialize the vertex buffer with indexing enabled
vertexBuffer.Init(true);

// Add vertices to the buffer
vertexBuffer.Add(new Vertex(/* vertex data */));
vertexBuffer.Add(new Vertex(/* vertex data */));
vertexBuffer.Add(new Vertex(/* vertex data */));

// Add indices to define the order of vertices
vertexBuffer.AddIndex(0);
vertexBuffer.AddIndex(1);
vertexBuffer.AddIndex(2);

// The indices added will define a triangle using the first three vertices added.