As I read in OpenGL matrices are column major. It means that if I create a 16 element array first four elements are the first column in matrix. Is it the same for Direct3D or any transformation's required.
|
Heishe is right about memory layout and matrices being the same, but his answer is somewhat misleading. Such things as right-handed or left-handed matrices don't exist. Be it a right- or left- handed coordinate system, math and the matrix stays the same, matrix operations give the same result for both of these systems. How we will interpret the data later, thats the difference. In OpenGL, matrix operations are pre-concatenated, which means concatenated transformations are applied from right to left. Direct3D, however, applies concatenated transformations from left to right. So what you need to do is to match the order of operation in OpenGL to the order of Direct3D. When writing OpenGL code, you apply the transform that you want to occur first last; when writing DirectX you're doing the opposite. Let's say you just transformed vector |
|||
|
|
DirectX matrices are right-handed and OpenGL requires left handed matrices, but while OpenGLs matrices are column-major, DirectX's matrices are row-major, so they're layout in memory is the same. |
|||
|
|
Neither D3D nor OpenGL specify or enforce a matrix handedness. True, the matrix stack functions in OpenGL are RH, but there's absolutely nothing to stop you from writing your own matrix library (or using a 3rd party one) that uses LH coords and loading the result using glLoadMatrixf. Likewise D3D has a full set of both RH and LH matrix functions. This is an old old old misunderstanding and needs to be put to bed. Regarding row-major vs column major, please see the following: http://www.opengl.org/resources/faq/technical/transformations.htm:
|
|||
|
|