Jump to content

  • Log In with Google      Sign In   
  • Create Account

DirectX 9 Effect framework and XNA math problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Shockwave   Members   -  Reputation: 167

Like
0Likes
Like

Posted 15 February 2011 - 08:15 AM

I've decided to change math library in my engine (GAPI - DirectX9) from D3DX to XNA from the new DX SDK. The problem is that I can't find a way to pass my matrices to shader through Effect framework SetMatrix function. I tried (float*), (D3DMATRIX *) and many other things but no success.

Here's a structure of XMMATRIX according to SDK help:
typedef struct _XMMATRIX {
    union {
        XMVECTOR r[4];
        struct {
            FLOAT _11;
            FLOAT _12;
            FLOAT _13;
            FLOAT _14;
            FLOAT _21;
            FLOAT _22;
            FLOAT _23;
            FLOAT _24;
            FLOAT _31;
            FLOAT _32;
            FLOAT _33;
            FLOAT _34;
            FLOAT _41;
            FLOAT _42;
            FLOAT _43;
            FLOAT _44;
        };
        FLOAT m[4][4];
    };
} XMMATRIX;
Please if anyone know how to solve this issue (pass XMMATRIX to fx shader through SetMatrix function) I'd gladly listen to the solution :)

edit:
In drawScene function I have:
HR(mFX->SetMatrix(mhP, &mProj));
where mFX ->
ID3DXEffect*  mFX;
mhP->
D3DXHANDLE mhP;
mProj ->
XMMATRIX mProj;
If I use D3DX matrix - everything is fine. But if I use XMMATRIX - I receive the following compiler error: error C2664: 'ID3DXEffect::SetMatrix' : cannot convert parameter 2 from 'XMMATRIX *' to 'const D3DXMATRIX *' on this line.

Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 4926

Like
0Likes
Like

Posted 15 February 2011 - 10:04 AM

but no success

Relalize that your post is essentially: "I have some code. It doesn't work. What's wrong?"

Post a minimal block of code that illustrates your issue, including your error checking, and describe why you say there's "no success."

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 andur   Members   -  Reputation: 595

Like
1Likes
Like

Posted 15 February 2011 - 10:41 PM

You should be able to use SetValue to pass in the bytes directly.

Something like: mFX->SetValue(mhP, &mProj, sizeof(mProj));

#4 Shockwave   Members   -  Reputation: 167

Like
0Likes
Like

Posted 16 February 2011 - 04:40 AM

You should be able to use SetValue to pass in the bytes directly.

Something like: mFX->SetValue(mhP, &mProj, sizeof(mProj));

Thank you very much andur!

A friend of mine told me another way to do this:
mFX->SetMatrix(mhP, (const D3DXMATRIX *)&mProj._11);





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS