Advertisement

Directx 11 with C++: how the indices works?

Started by February 06, 2018 08:58 PM
1 comment, last by matt77hias 6 years, 11 months ago

i'm trying understand how works the Indices.

if the Primtive is D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST then  6 Vertex are 2 triangles(and  i did that before).
the Indices avoid 6 Vertex for 2 triangles... these is  what i know. but i don't understand these line:


DWORD indices[] = {
    0, 1, 2,
    0, 2, 3,
};

the numbers are the Vertex array\vector elements?
can anyone explain more about it?

Your vertex array contains 4 vertices which have an associated index, indicating the position of the vertex in the vertex array.

Your index array contains the indices that make up your geometric primitives which consist of a number of vertices.

The topology describes how the index array should be interpreted. For a triangle list, this means that three consecutive indices make up one triangle, the next three consecutive indices, another triangle and so on.

In your case, you describe 2 triangles: a triangle constituted by the vertices at index 0, 1 and 2, and a second triangle constituted by the vertices at index 0, 2 and 3.

The idea behind the index array is to reuse the same vertices between multiple geometric primitives to reduce memory usage (the index is much smaller than a vertex) and reduce vertex shader executions ("shared" vertices are only processed once).

🧙

This topic is closed to new replies.

Advertisement