GLROTATE(3G)
π« GLROTATE β bestie edition π«
okay so this is glRotated and glRotatef from the 3G manual (yes that's the OpenGL one, we're fancy here π). Sit down, grab a strawberry drink π, and let's spin some matrices together.
β¨ NAME β¨
glRotated, glRotatef β multiply the current matrix by a rotation matrix. that's it. that's the whole job. iconic behavior honestly π
π§ C SPECIFICATION π§
void glRotated( GLdouble angle,
GLdouble x,
GLdouble y,
GLdouble z )
void glRotatef( GLfloat angle,
GLfloat x,
GLfloat y,
GLfloat z )
one's double, one's float. pick your fighter π
πΈ PARAMETERS πΈ
angleβ the angle of rotation, in degrees. not radians. degrees bestie, we're not doing trig homework here πx,y,zβ the x, y, and z coordinates of a vector, respectively. yes respectively, they're in order, relax π«Ά
π DESCRIPTION π
glRotate produces a rotation of angle degrees around the vector (x,y,z). so like, you pick an axis, you pick how far to spin, and boom, rotation β¨
The current matrix (see glMatrixMode) gets multiplied by a rotation matrix, and the product replaces the current matrix β as if glMultMatrix were called with the following matrix as its argument:
x2(1βc)+c xy(1βc)βzs xz(1βc)+ys 0
βyx(1βc)+zs y2(1βc)+c yz(1βc)βxs 0β
xz(1βc)βys yz(1βc)+xs z2(1βc)+c 0
0 0 0 1
Where c=cos(angle), s=sin(angle), and ||(x,y,z)||=1 (if not, the GL will normalize this vector). so don't stress about your vector being unit length, it's got you π«Ά
If the matrix mode is either GL_MODELVIEW or GL_PROJECTION, all objects drawn after glRotate is called are rotated. every single one. the whole friend group is coming with you π
Use glPushMatrix and glPopMatrix to save and restore the unrotated coordinate system. this is your "wait, put it back the way it was" button and it is SO important, no cap.
π NOTES π
This rotation follows the right-hand rule, so if the vector (x,y,z) points toward the user, the rotation will be counterclockwise. right hand rule besties, it's giving physics class but make it cute π
π ERRORS π
GL_INVALID_OPERATION is generated if glRotate is executed between the execution of glBegin and the corresponding execution of glEnd.
β οΈ so likeβ¦ do NOT call this betweenglBeginandglEnd. the GL will simply not have it and will throw hands. it's giving "read the room" π€
π₯ ASSOCIATED GETS π₯
glGetwith argumentGL_MATRIX_MODEglGetwith argumentGL_COLOR_MATRIXglGetwith argumentGL_MODELVIEW_MATRIXglGetwith argumentGL_PROJECTION_MATRIXglGetwith argumentGL_TEXTURE_MATRIX
π SEE ALSO π
glMatrixMode(3G), glMultMatrix(3G), glPushMatrix(3G), glScale(3G), glTranslate(3G)
and that's the whole page bestie!! this was GLROTATE(3G) from the 3G manual β same title, same section, just delivered with the energy it deserved. now go rotate something and make it the main character π
β¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms