I store my matrix like that :m16[ 0 ] = 1.0f; m16[ 4 ] = 0.0f; m16[ 8 ] = 0.0f; m16[ 12 ] = x; m16[ 1 ] = 0.0f; m16[ 5 ] = 1.0f; m16[ 9 ] = 0.0f; m16[ 13 ] = y; m16[ 2 ] = 0.0f; m16[ 6 ] = 0.0f; m16[ 10 ] = 1.0f; m16[ 14 ] = z; m16[ 3 ] = 0.0f; m16[ 7 ] = 0.0f; m16[ 11 ] = 0.0f; m16[ 15 ] = 1.0f;
I have renderer on Direct3D11 and OpenGL, and I have to transpose to have it works on D3D11.
I don't understand what you said about one matrix who works for all, maybe one #ifdef who change index ?
The reason why you need to transpose your matrix for d3d11 it is because the shader matrix memory layout is the transpose of the matrix layout you have store on the CPU side by default. So instead of 12,13,14. The element at 3,7,11 represent position. But in OpenGL GLSL shaders the matrix layout is the same at the one you have on the CPU side, which is why there is no need to transpose for GLSL.