GLSCALE(3G)

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

πŸ’… GLSCALE β€” bestie edition (it's a 3G manual page, iykyk)

okay so. you wanna scale stuff. non-uniformly. along all three axes at once. say less, queen β€” that's literally what glScaled and glScalef are for ✨


🌸 NAME 🌸

glScaled, glScalef β€” multiply the current matrix by a general scaling matrix. that's it, that's the whole job description 🫢


πŸŽ€ C SPECIFICATION πŸŽ€

here's the exact signature, don't @ me:

void glScaled( GLdouble x,
               GLdouble y,
               GLdouble z )
void glScalef( GLfloat x,
               GLfloat y,
               GLfloat z )

two flavors, same energy. one's double, one's float. pick your fighter πŸ’…


πŸ¦‹ PARAMETERS πŸ¦‹

  • x, y, z β€” the scale factors along the x, y, and z axes respectively. like, how much are we stretching each direction. that's the whole thing πŸ“

✨ DESCRIPTION ✨

glScale produces a nonuniform scaling along the x, y, and z axes. nonuniform meaning it does not have to be the same in every direction β€” you can squish one axis and stretch another, main character behavior honestly. the three parameters tell you the desired scale factor along each of the three axes.

the current matrix (peep glMatrixMode) gets multiplied by this scale matrix, and the product replaces the current matrix, exactly as if glScale had been called with this matrix as its argument:

                                       x 0 0 0
                                      ⎝0 y 0 0⎠
                                       0 0 z 0
                                       0 0 0 1

if the matrix mode is either GL_MODELVIEW or GL_PROJECTION, then all objects drawn after glScale is called are scaled. so like. everything downstream gets the vibe. no takebacks unless you do takebacks πŸ‘‘

speaking of takebacks β€” use glPushMatrix and glPopMatrix to save and restore the unscaled coordinate system. save state, do your scaling, pop it back. iconic combo, they're besties fr fr 🫢


πŸ’€ NOTES πŸ’€

if scale factors other than 1 are applied to the modelview matrix and lighting is enabled, lighting often appears wrong. yeah. it's giving cursed. 😭

in that case, enable automatic normalization of normals by calling glEnable with the argument GL_NORMALIZE. that's the fix, bestie, write it down πŸ“


πŸ”₯ ERRORS πŸ”₯

  • GL_INVALID_OPERATION is generated if glScale is executed between the execution of glBegin and the corresponding execution of glEnd.

translation: do not call this inside a glBegin/glEnd block. the GL gods will simply Not Allow It πŸ™ˆ


⭐ ASSOCIATED GETS ⭐

all the glGet calls that vibe with this one:

  • 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 🌈

go read these next, they're all in the same friend group:

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

okay that's the whole page, you ate it, you understood it, you're gonna go scale something beautiful now πŸ’œ and yes this was the GLSCALE(3G) manual page, signing off, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from