M4ST3RX
M4ST3RX

Reputation: 31

Why does my code output 2 diagonal lines on one side of the cube? Am I mixing up some verticies?

I am using TRIANGLESTRIP topology trying to display the wireframe of a cube. Here is the vertex I use:

g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );

SimpleVertex vertices[] =
{
    { XMFLOAT3(-1.0f, 1.0f, -1.0f), XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f) }, // 0 Front-bottom-left
    { XMFLOAT3(1.0f, 1.0f, -1.0f), XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f) }, // 1 Front-bottom-right
    { XMFLOAT3(1.0f,  1.0f, 1.0f), XMFLOAT4(0.0f, 0.0f, 1.0f, 1.0f) }, // 2 Front-top-left
    { XMFLOAT3(-1.0f,  1.0f, 1.0f), XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f) }, // 3 Front-top-right
    { XMFLOAT3(-1.0f, -1.0f,  -1.0f), XMFLOAT4(1.0f, 0.0f, 1.0f, 1.0f) }, // 4 Back-bottom-left
    { XMFLOAT3(1.0f, -1.0f,  -1.0f), XMFLOAT4(0.0f, 1.0f, 1.0f, 1.0f) }, // 5 Back-bottom-right
    { XMFLOAT3(1.0f,  -1.0f,  1.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f) }, // 6 Back-top-left
    { XMFLOAT3(-1.0f,  -1.0f,  1.0f), XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f) }  // 7 Back-top-right
};

and these are my indicies:

WORD indices[] =
{
    0,1,3,
    3,2,1,
    1,5,2,
    2,5,6,
    5,4,1,
    1,0,4,
    4,0,3,
    3,7,4,
    4,5,7,
    7,5,6,
    6,2,3,
    3,7,6
};

enter image description here

Upvotes: 0

Views: 47

Answers (0)

Related Questions