Jump to content
  • Advertisement
Sign in to follow this  
XeonXT

ID3DXEffect::SetMatrix using Custom Matrix Format

This topic is 2976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm rather wary of this line that I just wrote:

myEffect->SetMatrix(handle,(D3DXMATRIX*)&myMatrix);


"myMatrix" is a struct of my own type Matrix. I *think* that it has the same member data as D3DXMATRIX:

struct Matrix
{
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
...etc...
};

...right?

My question: is this legal?? Can I pull the wool over D3DX's eyes if my matrix format is the same as D3DXMATRIX by just casting away my troubles? Or is my computer going to splode and such when I finally run this bad boy? I can't test this at the moment because too many other subsystems are being overhauled, hence the need to ask.

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Provided there's no padding applied to your struct (and I can't imagine why there would be), then your layout is correct.

For what it's worth, I do this in my D3D renderer (more or less - in my case I'm casting an array of floats), and I've never had any problems.

Share this post


Link to post
Share on other sites
Thanks very much!

I was finally able to test it and, by a long series of successively more improbable miracles, everything worked!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!