Could someone answer my questions, please?
I am using XNA Math library in my application.
The question is:
Is it safe to use XNA Math types in a structure copied into the mapped resource of device's context?
Imagine such model constant buffer, please:
|struct CConstantBuffer // Allocate with proper alignment |
| XMMATRIX g_Proj; // float4x4 |
| XMFLOAT4X4 g_View; // float4x4 |
| XMFLOAT4X4A g_World; // float4x4 |
| XMFLOAT4A g_LightCol; // float3 |
| XMVECTOR g_LightDir; // float4 |
I have implemented aligned constant buffers with such types.
It works, because these types are arrays of floats.
I am not sure, that this is a safe solution.
Is not it?
The second question:
Is it 'legal' to use XNA Math types without calling the constructors of these types?
This is possible by casting memory buffers of other types.
XNA types are non-virtual structures, and would be allocated by any method, I hope.
After the allocation of variables, new values would be assinged using XMLoadFloat4, etc.
Thank you very much