locked
Directx12 draw rectangle RRS feed

  • 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

  • DirectX forums can be found here.

    http://xboxforums.create.msdn.com/forums/76.aspx'

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Mike Laughlin Friday, July 1, 2016 12:39 PM
    • Marked as answer by Just Karl Tuesday, July 12, 2016 10:12 PM
    Thursday, June 30, 2016 8:47 PM

All replies

  • This is clearly not a question about the Samll Basic language. You should look for a forum dedicated to directx

    Jan [ WhTurner ] The Netherlands

    Thursday, June 30, 2016 11:59 AM
  • DirectX forums can be found here.

    http://xboxforums.create.msdn.com/forums/76.aspx'

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Mike Laughlin Friday, July 1, 2016 12:39 PM
    • Marked as answer by Just Karl Tuesday, July 12, 2016 10:12 PM
    Thursday, June 30, 2016 8:47 PM