Note that there are some explanatory texts on larger screens.

plurals
  1. POWHy does my triangle refuse to rotate?
    text
    copied!<p>I have a triangle created in DirectX11. I now want to play around with viewport and world matrices to help my understanding of them, so Id like to simply rotate the triangle around the Z axis. My code for attempting to do that is below. </p> <pre><code>void Render(void) { if (d3dContext_ == 0) return; XMMATRIX view = XMMatrixIdentity(); XMMATRIX projection = XMMatrixOrthographicOffCenterLH(0.0f, 800.0f, 0.0f, 600.0f, 0.1f, 100.0f); . XMMATRIX vpMatrix_ = XMMatrixMultiply(view, projection); XMMATRIX translation = XMMatrixTranslation(0.0f, 0.0f, 0.0f); XMMATRIX rotationZ = XMMatrixRotationZ(30.0f); XMMATRIX TriangleWorld = translation * rotationZ; XMMATRIX mvp = TriangleWorld*vpMatrix_; mvp = XMMatrixTranspose(mvp); float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f }; d3dContext_-&gt;ClearRenderTargetView(backBufferTarget_, clearColor); unsigned int stride = sizeof(VertexPos); unsigned int offset = 0; d3dContext_-&gt;IASetInputLayout(inputLayout_); d3dContext_-&gt;IASetVertexBuffers(0, 1, &amp;vertexBuffer_, &amp;stride, &amp;offset); d3dContext_-&gt;IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); d3dContext_-&gt;VSSetShader(solidColorVS_, 0, 0); d3dContext_-&gt;PSSetShader(solidColorPS_, 0, 0); d3dContext_-&gt;UpdateSubresource(mvpCB_, 0, 0, &amp;mvp, 0, 0); d3dContext_-&gt;VSSetConstantBuffers(0, 1, &amp;mvpCB_); d3dContext_-&gt;Draw(3, 0); swapChain_-&gt;Present(0, 0); } </code></pre> <p>It just displays the standard triangle, its as if it does not take notice of the mvp. My desired effect is the rotation as controlled by <code>XMMATRIX rotationZ = XMMatrixRotationZ(30);</code>.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload