Hi I started to study directx12. I don't have any knowledge on prior versions.
I am following this example program HelloWorldTriangle which rendering a triangle. I want to draw a rectangle so,
I changed
Vertex triangleVertices[] =
{
{ { 0.0f, 0.25f * m_aspectRatio, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },
{ { 0.25f, -0.25f * m_aspectRatio, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } },
{ { -0.25f, -0.25f * m_aspectRatio, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }
};
m_commandList->DrawInstanced(3, 1, 0, 0);
to
Vertex triangleVertices[] =
{
{ { 0.0f, 0.25f * m_aspectRatio, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },
{ { 0.25f, -0.25f * m_aspectRatio, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } },
{ { -0.25f, -0.3f * m_aspectRatio, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } },
{ { -0.25f, -0.2f * m_aspectRatio, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } },
};
m_commandList->DrawInstanced(4, 1, 0, 0);
But still draws a triangle with different angle .. Please explain what I have to change to get a rectangle.
It will be really helpful for me if you give some links or books to headstart directx12 ..
Thanks in advance ..
I don't want to download the whole code, but familiarize yourself with Topology concept. In this project primitive topology is set to D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, so it will draw triangle using 3 vertices, and then it will need 3 more to draw another one. If you want to draw second triangle using last 2 vertices and new one you have to use trianglestrip, however make sure your new triangle faces correct way (or you set D3D12_GRAPHICS_PIPELINE_STATE_DESC RasterizerState.CullMode = D3D12_CULL_MODE_NONE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With