1
\$\begingroup\$

I am trying to Rotate a textured quad in directX however I think i am missing something. I am pretty sure it is because i am applying transformations to the WorldMatrix instead of the ObjectWorld, however i do not have an object world matrix so i am unsure how i would get that since i am not storing much except the texture and the position of 4 vertices directly to the buffer and only updated when it is needed.

here is what i have tried

bool GraphicsClass::Render(float deltatime)
{
D3DXMATRIX worldMatrix, viewMatrix, projectionMatrix, orthoMatrix, rotationZ;
bool result;


// Clear the buffers to begin the scene.
m_D3D->BeginScene(0.0f, 0.0f, 0.0f, 0.0f);

// Generate the view matrix based on the camera's position.
m_Camera->Render();
//DrawingStuff
// Get the world, view, projection, and ortho matrices from the camera and d3d objects.
m_Camera->GetViewMatrix(viewMatrix);
m_D3D->GetWorldMatrix(worldMatrix);
m_D3D->GetProjectionMatrix(projectionMatrix);
m_D3D->GetOrthoMatrix(orthoMatrix);
//Transform World Matrix with a rotation matrix
D3DXMatrixRotationZ(&rotationZ, 90.0f);
D3DXMatrixMultiply(&worldMatrix, &worldMatrix, &rotationZ);
// Turn off the Z buffer to begin all 2D rendering.
m_D3D->TurnZBufferOff();
// Put the bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing.
result = m_Bitmap->Render(m_D3D->GetDeviceContext(), 124, 124);
if(!result)
{
    return false;
}

// Render the bitmap with the texture shader.
result = m_TextureShader->Render(m_D3D->GetDeviceContext(), m_Bitmap->GetIndexCount(), worldMatrix, viewMatrix, orthoMatrix, m_Bitmap->GetTexture());
if(!result)
{
    return false;
}

// Turn the Z buffer back on now that all 2D rendering has completed.
m_D3D->TurnZBufferOn();

// Present the rendered scene to the screen.
m_D3D->EndScene();

return true;
}

the full code can actually be downloaded from http://www.rastertek.com/dx11tut05.html with the minor difference that render takes in delta-time since last frame using a custom timer class which is not provided by them as well as a few minor tweaks but it is mostly the same.

i did find this http://www.rastertek.com/dx11tut25.html which i may try to implement however that is not really what i want, i want to rotate the actual quad, not the texture.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.