Jump to content
  • Advertisement
Sign in to follow this  
nirVaan

cpoying user defiend matric class to a directx matrix class

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

hi i have been working on a game engine project for my uni, and we want it to be as platform neutral as possible. so we have made a math framework which includes matrices vectors etc.. can any one point out a strategy to quickly copy the elements of our user defined matrix class (TMatrix4) to a D3DX matrix class class TMatrix4 { union { struct { float _11, _12, _13, _14; float _21, _22, _23, _24; float _31, _32, _33, _34; float _41, _42, _43, _44; }; float m[4][4]; }; ..... } and it seems the D3DXMatrix structure derives from the D3DMATRIX structure which has pretty much the same signature as of our Matrix structure typedef struct _D3DMATRIX { union { struct { float _11, _12, _13, _14; float _21, _22, _23, _24; float _31, _32, _33, _34; float _41, _42, _43, _44; }; float m[4][4]; }; } D3DMATRIX; so can we do a memcpy of it.will it work??? D3DXMatrix *X; TMatrix4 *Y; memcpy ( x , Y , sizeof(TMatrix4 )); thankz

Share this post


Link to post
Share on other sites
Advertisement
Yeah it should work. In fact if you're working with both D3D and OpenGL, the matrices are actually laid out identically in memory (they're just interpreted differently) so that won't be a problem.

Also if you don't want to memcpy you should be able to just provide D3D functions with a pointer to a TMatrix4 that's been casted to D3DMATRIX*.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!