GLMULTMATRIX(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

✨ GLMULTMATRIX ✨

okay bestie, welcome to GLMULTMATRIX(3G) β€” the 3G manual section, we love her πŸ’–

🌸 NAME 🌸

glMultMatrixd, glMultMatrixf β€” multiply the current matrix with the specified matrix 🧚


πŸ’… C SPECIFICATION πŸ’…

void glMultMatrixd( const GLdouble *m )
void glMultMatrixf( const GLfloat *m )

πŸŽ€ PARAMETERS πŸŽ€

  • m β€” points to 16 consecutive values that get used as the elements of a 4Γ—4 column-major matrix. sixteen!! consecutive!! values!! that's the whole vibe, no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

glMultMatrix multiplies the current matrix by the one you handed it with m, and then replaces the current matrix with the product. so it's not like, a peek, it's a full glow-up β€” the old matrix is gone, the product is the new main character πŸ‘‘

which matrix is "the current matrix" tho? that's decided by the current matrix mode (go check glMatrixMode). it's either the projection matrix, the modelview matrix, or the texture matrix. that's the whole lineup fr fr.


πŸ”₯ EXAMPLES πŸ”₯

so if the current matrix is C, and the coordinates you're transforming are v=(v[0],v[1],v[2],v[3]), then the current transformation is CΓ—v, or:

                             c[0] c[4] c[8]  c[12]   v[0]
                            ⎝c[1] c[5] c[9]  c[13]βŽ Γ—βŽv[1]⎠
                             c[2] c[6] c[10] c[14]   v[2]
                             c[3] c[7] c[11] c[15]   v[3]

and now the moment you've been waiting for: calling glMultMatrix with an argument of m=m[0],m[1],...,m[15] replaces the current transformation with (CΓ—M)Γ—v, or:

                 c[0] c[4] c[8]  c[12]   m[0] m[4] m[8]  m[12]   v[0]
                ⎝c[1] c[5] c[9]  c[13]βŽ Γ—βŽm[1] m[5] m[9]  m[13]βŽ Γ—βŽv[1]⎠
                 c[2] c[6] c[10] c[14]   m[2] m[6] m[10] m[14]   v[2]
                 c[3] c[7] c[11] c[15]   m[3] m[7] m[11] m[15]   v[3]

where 'Γ—' denotes matrix multiplication, and v is represented as a 4Γ—1 matrix. iconic math behavior honestly πŸ’œ


πŸ’€ NOTES πŸ’€

  • so even tho you can specify the elements of the matrix with single or double precision, the GL might store or operate on those values in less than single precision. not me finding that out the hard way 😭
  • in lots of computer languages, 4Γ—4 arrays are represented in row-major order. but the transformations we just described? those represent these matrices in column-major order. don't get it twisted bestie.
  • the order of the multiplication is important, and I mean it. like, for example: if the current transformation is a rotation, and glMultMatrix is called with a translation matrix, the translation is done directly on the coordinates to be transformed, while the rotation is done on the results of that translation. different order = different whole situation. periodt.

😀 ERRORS 😀

  • GL_INVALID_OPERATION is generated if glMultMatrix is executed between the execution of glBegin and the corresponding execution of glEnd. so like, do NOT do that. she will not forgive you πŸ™ˆ

πŸ‘‘ ASSOCIATED GETS πŸ‘‘

  • glGet with argument GL_MATRIX_MODE
  • glGet with argument GL_COLOR_MATRIX
  • glGet with argument GL_MODELVIEW_MATRIX
  • glGet with argument GL_PROJECTION_MATRIX
  • glGet with argument GL_TEXTURE_MATRIX

🌈 SEE ALSO 🌈

  • glLoadIdentity(3G)
  • glLoadMatrix(3G)
  • glMatrixMode(3G)
  • glPushMatrix(3G)

k bye bestie, go multiply some matrices responsibly πŸ’–βœ¨ that was GLMULTMATRIX(3G) from the 3G manual, mwah πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from