왼손 좌표계 / 오른손 좌표계
왼손 좌표계 - 시계방향으로 그려야 그려진다
오른손 좌표계 - 반시계방향으로 그려야 그려진다


Triangle
VertexBuffer
vertices[0].Position = Vector3(-0.5f, +0.0f, 0.0f);
vertices[1].Position = Vector3(+0.0f, +0.5f, 0.0f);
vertices[2].Position = Vector3(+0.5f, +0.0f, 0.0f);

vertices[0].Position = Vector3(-0.5f, +0.0f, 0.0f);
vertices[1].Position = Vector3(+0.5f, +0.0f, 0.0f);
vertices[2].Position = Vector3(+0.0f, +0.5f, 0.0f);

VertexBuffer2
vertices2[0].Position = Vector3(-0.5f, -0.5f, 0.0f);
vertices2[1].Position = Vector3(+0.0f, +0.0f, 0.0f);
vertices2[2].Position = Vector3(+0.5f, -0.5f, 0.0f);

Rectangle
vertices[0].Position = Vector3(-0.5f, -0.5f, 0.0f);
vertices[1].Position = Vector3(-0.5f, +0.5f, 0.0f);
vertices[2].Position = Vector3(+0.5f, -0.5f, 0.0f);
vertices[3].Position = Vector3(+0.5f, -0.5f, 0.0f);
vertices[4].Position = Vector3(-0.5f, +0.5f, 0.0f);
vertices[5].Position = Vector3(+0.5f, +0.5f, 0.0f);


RasterizerState FillMode_Wireframe
{
FillMode = Wireframe;
};
technique11 T0
{
pass P0
{
SetRasterizerState(FillMode_Wireframe);
SetVertexShader(CompileShader(vs_5_0, VS()));
SetPixelShader(CompileShader(ps_5_0, PS_R()));
}
}
셰이더의 Rasterizer에서 FillMode를 Wireframe으로 설정해준다

Update
if (Keyboard::Get()->Press(VK_RIGHT))
vertices[0].Position.x += 1.0f * Time::Delta();
else if (Keyboard::Get()->Press(VK_LEFT))
vertices[0].Position.x -= 1.0f * Time::Delta();
//Update된 변수들을 GPU에 넘겨주는 과정
D3D::GetDC()->UpdateSubresource(vertexBuffer, 0, NULL, vertices, sizeof(Vertex) * 6, 0);

좌표가 -0.5 아래로 내려가면 그리기 순서가 바뀌어서 보이지 않게 된다
'> Study > DirectX' 카테고리의 다른 글
| [DirectX] Texture (0) | 2024.01.23 |
|---|---|
| [DirectX] Grid, Camera (0) | 2024.01.04 |
| [DirectX] World Matrix (2) | 2023.12.21 |
| [DirectX] Vertex (1) | 2023.12.20 |
| [DirectX] (1) | 2023.12.20 |