Using column format in specification and blue book

I just read the OpenGL FAQ here: http://www.opengl.org/resources/faq/technical/transformations.htm

Look at their section called "9.005. OpenGL matrices for columns or rows?" Below said:

"Unfortunately, the use of the column format in the specification and the blue book has led to endless confusion in the OpenGL developer community. The designation of the column indicates that the matrices are not laid out in memory, as the programmer expected."

Now, I tried my best to always transfer matrix data to OpenGL in column order so as not to waste OpenGL processing time on transpose operations. But does this FAQ answer the question that I do not need to do this?

+6
source share
1 answer

Frequently asked questions are a bit outdated. Technically, with OpenGL-3, you can transfer matrices in row order format by setting the transpose parameter glUniformMatrix to true.

However, I personally find that the main column orders a huge advantage: it allows you to directly access the base vectors of the coordinate system (transformation) that the matrix describes. Look at your typical transformation matrix.

X_x Y_x Z_x T_x X_y Y_y Z_y T_y X_z Y_z Z_z T_z W_a W_b W_c W_w 

X, Y and Z are the base vectors of the coordinate system you are transforming into, T is the offset.

Now look at the indexing used by OpenGL

 0 4 8 c 1 5 9 d 2 6 ae 3 7 bf 

So, at offset 0 you find the vector X, at offset 4 you find Y, offset 8 gives Z, and offset c gives T. You can access them directly, pass them to vector manipulation functions, such as

 float vec4_length3(float v[4]); 

straight:

 float M[16] = {...}; float T_length = vec4_length3(&M[c]); 

instead of first abandoning these vectors from the matrix in parts.

+8
source

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


All Articles