• Breaking News

    weird behaviour using XMMATRIX variables inside a c++ function Hello everybody, i'm learning DirectX11 and i can't understand why the following code doesn't work as expected. I have a function that takes 3 XMMATRIX and multiplies them to get the WVP matrix. void DummyShader::PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix) { WVP = worldMatrix * viewMatrix * projectionMatrix; } The 3 XMMATRIX are correctly read, but the resulting WVP matrix contains some absurd values. The function behaves as expected if i replace the offending line with the following: XMMATRIX temp1 = projectionMatrix; XMMATRIX temp2 = viewMatrix; XMMATRIX temp3 = worldMatrix; WVP = temp3 * temp2 * temp1; But it doesn't make any sense to me, what's the difference? I'm sure i'm missing something veeeery obvious, but i'm not that experienced in the field. This is a fully reproducible example of my problem: //main.cpp #include #include "DummyShader.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) { DummyShader* dummyShader = new DummyShader(); XMMATRIX world = XMMatrixIdentity(); XMMATRIX view = XMMatrixIdentity(); XMMATRIX projection = XMMatrixIdentity(); dummyShader->PrepareToDraw(world,view,projection); return 0; } //DummyShader.h using namespace DirectX; class DummyShader { public: XMMATRIX WVP; DummyShader(); ~DummyShader(); void PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix); }; //DummyShader.cpp #include "DummyShader.h" DummyShader::DummyShader() { } DummyShader::~DummyShader() { } void DummyShader::PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix) { WVP = worldMatrix * viewMatrix * projectionMatrix; } Any hint? Thanks in advance https://ift.tt/eA8V8J

    Hello everybody, i'm learning DirectX11 and i can't understand why the following code doesn't work as expected. I have a function that takes 3 XMMATRIX and multiplies them to get the WVP matrix. void DummyShader::PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix) { WVP = worldMatrix * viewMatrix * projectionMatrix; } The 3 XMMATRIX are correctly read, but the resulting WVP matrix contains some absurd values. The function behaves as expected if i replace the offending line with the following: XMMATRIX temp1 = projectionMatrix; XMMATRIX temp2 = viewMatrix; XMMATRIX temp3 = worldMatrix; WVP = temp3 * temp2 * temp1; But it doesn't make any sense to me, what's the difference? I'm sure i'm missing something veeeery obvious, but i'm not that experienced in the field. This is a fully reproducible example of my problem: //main.cpp #include <windows.h> #include "DummyShader.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) { DummyShader* dummyShader = new DummyShader(); XMMATRIX world = XMMatrixIdentity(); XMMATRIX view = XMMatrixIdentity(); XMMATRIX projection = XMMatrixIdentity(); dummyShader->PrepareToDraw(world,view,projection); return 0; } //DummyShader.h using namespace DirectX; class DummyShader { public: XMMATRIX WVP; DummyShader(); ~DummyShader(); void PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix); }; //DummyShader.cpp #include "DummyShader.h" DummyShader::DummyShader() { } DummyShader::~DummyShader() { } void DummyShader::PrepareToDraw(XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix) { WVP = worldMatrix * viewMatrix * projectionMatrix; } Any hint? Thanks in advance

    from GameDev.net https://ift.tt/2TSJTEq

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728