GLTRANSLATE(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’– NAME πŸ’–

glTranslated, glTranslatef β€” bestie, these two take your current matrix and multiply it by a translation matrix. That's it. That's the whole job. Move stuff in 3D space, slay. ✨


πŸŽ€ C SPECIFICATION πŸŽ€

okay so here's the literal signature, no cap, copy it exactly:

void glTranslated( GLdouble x,
                   GLdouble y,
                   GLdouble z )
void glTranslatef( GLfloat x,
                   GLfloat y,
                   GLfloat z )

one's the double girlie, one's the float girlie. same energy, different precision. πŸ’…


🌸 PARAMETERS 🌸

  • x, y, z β€” these three are the x, y, and z coordinates of your translation vector. i.e. how far you're yeeting everything along each axis. πŸ¦‹

✨ DESCRIPTION ✨

okay so glTranslate produces a translation by (x,y,z). simple. iconic. the way that it works is:

your current matrix (peep glMatrixMode for which one that is, iykyk) gets multiplied by this translation matrix, and the product replaces the current matrix. it's literally as if you'd called glMultMatrix and handed it this exact matrix as the argument:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

see how the x, y, z just sit there in the last column, doing nothing, minding their business, shifting everything? that's the whole trick bestie πŸ’€

if the matrix mode is either GL_MODELVIEW or GL_PROJECTION, then all objects drawn after a call to glTranslate are translated. every single one. they all moved. no take-backs. πŸ‘‘

and if you want your coordinate system back the way it was (untranslated, untouched, fresh out the box), use glPushMatrix and glPopMatrix to save and restore it. that's the save-scumming of OpenGL and honestly? we love her for it. 🫢


πŸ’€ ERRORS πŸ’€

GL_INVALID_OPERATION gets generated if glTranslate is executed between the execution of glBegin and the corresponding execution of glEnd.

translation? inside a glBegin/glEnd block? absolutely NOT. the vibe check failed. don't do it. 😭

πŸ”₯ 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 ⭐

  • glMatrixMode(3G)
  • glMultMatrix(3G)
  • glPushMatrix(3G)
  • glRotate(3G)
  • glScale(3G)

go read those too, they're all in their main character era. 🌈


okay that's the whole page bestie, this was the GLTRANSLATE(3G) entry from the 3G manual section β€” mwah, sending you off with a kiss and a translated coordinate system πŸ’œπŸ§šβ€β™€οΈπŸ“

πŸ“¦ where this page comes from