Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:12:49+00:00 2026-06-18T15:12:49+00:00

I have an odd problem with my Direct3D11 application that I’m trying to resolve

  • 0

I have an odd problem with my Direct3D11 application that I’m trying to resolve for few hours already. The problem is that method:

void CameraClass::Render()
{
    XMFLOAT3 sUp, sLookAt, sRotationInRadians;

    sUp.x = 0.0f;
    sUp.y = 1.0f;
    sUp.z = 0.0f;

    sLookAt.x = 0.0f;
    sLookAt.y = 0.0f;
    sLookAt.z = 1.0f;

    sRotationInRadians.x = m_Rotation.x * 0.0174532925f;
    sRotationInRadians.y = m_Rotation.y * 0.0174532925f;
    sRotationInRadians.z = m_Rotation.z * 0.0174532925f;

    XMVECTOR vecLookAt = XMVectorSet( sLookAt.x, sLookAt.y, sLookAt.z, 0.0f );
    XMVECTOR vecUp = XMVectorSet( sUp.x, sUp.y, sUp.z, 0.0f );
    XMVECTOR vecPosition = XMVectorSet( m_Position.x , m_Position.y, m_Position.z, 0.0f );

    XMMATRIX RotationMatrix( XMMatrixRotationRollPitchYaw( sRotationInRadians.x, sRotationInRadians.y, sRotationInRadians.z ));

    vecLookAt = XMVector3TransformCoord( vecLookAt, RotationMatrix );
    vecUp = XMVector3TransformCoord( vecUp, RotationMatrix );

    vecLookAt += vecPosition;   

    m_ViewMatrix = XMMatrixLookAtLH( vecPosition, vecLookAt, vecUp );
}

Everything’s fine until it reaches that line:

m_ViewMatrix = XMMatrixLookAtLH( vecPosition, vecLookAt, vecUp );

Somehow it causes application crash ( switches to not responding to be correct ).

And here is how actual calls look like:

XMMATRIX ViewMatrix;
XMMATRIX ProjectionMatrix;
XMMATRIX WorldMatrix;

m_D3D->BeginScene( 0.0f, 0.0f, 0.0f, 1.0f );

m_Camera->Render();

m_D3D->GetWorldMatrix( WorldMatrix );
m_D3D->GetProjectionMatrix( ProjectionMatrix );

In advance, Vertex and Pixel shaders compile just fine, so that’s not a problem.
Most probably I’m doing something wrong with xnamath ( I’m completely new with it ), but I have no idea what on Earth that could be. Thanks in advance. I’ll provide more information if needed.

Edit@1: With dozens of changes I managed to get Projection and World matrices to work. Though I still can’t set View matrix. I changed the code, so it matches the actual one and got rid of what’s not important.

Edit@2: Breaking news from last minute: there isn’t a problem with XMMatrixLookAtLH function, because I decided to save the result to local variable and it works, but if I want to assign result matrix to class member then I get the crash. That’s most certainly interesting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:12:51+00:00Added an answer on June 18, 2026 at 3:12 pm

    After many hours spent attempting to solve this problem, I believe I have finally solved it.

    XMMATRIX represents a 16-byte aligned matrix and the unaligned allocation of the XMMATRIX causes this error when you attempt to copy the value. This would explain why it doesn’t always happen and why it works in different mode.

    The best solution I have found to this issue is to use an XMFLOAT4X4 to store the value.

    Here is a simple example:

    #include <windows.h>
    #include <xnamath.h>
    
    class Camera
    {
    protected:
        XMFLOAT4X4  view_;
    public:
        XMFLOAT4X4  const& Update()
        {
            XMStoreFloat4x4(&this->view_ , XMMatrixIdentity());
            return this->view_;
        }
    };
    
    int main()
    {
        Camera* cam = new Camera;
        XMFLOAT4X4 const& mat = cam->Update();
        XMMATRIX x = XMLoadFloat4x4(&mat);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an odd problem that I'm trying to solve in R: Let's say
I have an odd problem with Django. I have a set of objects that
I have an odd problem. I have a unit test that keeps getting stuck
I have a very odd problem. A class property is mysteriously reset between method
I have an extremely odd problem in my JUnit tests that I just can't
Have an odd problem with a 'Signature Pad I'm building for an employment application...
I have an odd problem that I've been beating my head into a wall
I have an odd problem in my jQuery code that loads in Drupal 7
I have an odd problem that I just can't seem to diagnose, and it
I have an odd problem. I'm trying to use Javascript to fetch me some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.