none
Directx12 draw rectangle

    Question



  • 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 ..

    • Edited by vivek1may Thursday, June 30, 2016 5:09 AM
    • Moved by litdev Thursday, June 30, 2016 2:40 PM
    Thursday, June 30, 2016 5:08 AM

Answers

All replies