Sign in to follow this  

ID3DXEffect::SetMatrix using Custom Matrix Format

This topic is 2669 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
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

This topic is 2669 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this