OpenGL VS DirectX Matrices

I only processed DirectX matrices

I read articles that say you cannot use DirectX matrix math libraries for OpenGL matrices.

but I also read that if your math is consistent, you can get similar results. This confuses me even more.

Can someone enlighten me? or If you cannot use DirectX math in openGL matrices. Does anyone know a good OpenGL matrix library?

any help in understanding the differences and the mathematical knowledge about them would be appreciated.

+4
source share
2 answers

I read articles that say you cannot use DirectX matrix math libraries for OpenGL matrices.

It is not right.

but I also read that if your math is consistent, you can get similar results.

The only difference is the default assumptions that OpenGL and DirectX make about their coordinate space of a normalized device. They use slightly different ranges and signs. However, this only converts to the conversion stack with an extra โ€œadapterโ€ matrix previously multiplied by it, and you are done with.

Index ordering may also be important, but modern OpenGL allows you to choose which order is used by the parameter for glUniformMatrix named "transpose"

+6
source

I would like to add datenwolf to the big answer, making it clear that the key perceived difference between OpenGL matrices and DirectX matrices is that they basically have a column format and a series of rows. (Column and row-major refers to how you write them in 4x4 format. If translations are displayed in the fourth column, that is, in the column column, on the contrary, for the row-major.)

Mathematicians will tell you that a major column is the right way to represent a matrix, primarily because it simplifies operations on them visually (on paper).

However, when it comes to OpenGL, the entire matrix is โ€‹โ€‹laid out in memory in a 16-element array with a shift occupying the 13th, 14th and 15th elements, according to the specification . Thus, it is easy to adapt the data to the matrix format.

+2
source

Source: https://habr.com/ru/post/1445174/


All Articles