简体   繁体   中英

OpenGL: What does glRotatef rotate?

When I call the glRotatef like this:

glRotatef(angle,0.0,1.0,0.0) //rotate about y-axis

I know it is to rotate by angle degrees about the y axis .
But, what is being rotated here? Which object exactly?

Probably a silly question, but I'm entirely new to this.

I was able to rotate a line about it's endpoint using the answer here , but I don't really understand how it works internally.

Nothing is being rotated, because OpenGL does not "store" objects.

glRotatef, like glMultMatrixf, is used to modify the currently selected transformation matrix. This has an effect on how things are drawn subsequently. One sets the matrices (and other stuff!) how one wants, and then one draws one's objects.

For more information, see the OpenGL redbook, and google around for the difference between "retained mode" and "immediate mode".

glRotate will act on the current matrix, which is by default GL_MODELVIEW . Doing so will affect any 3D object that you draw in the sequence. The current matrix is changed with glMatrixMode . The model-view matrix is then applied to any geometry rendered with glVertex , glDrawArrays , etc.

OpenGL-side matrices are now deprecated. If you use core OpenGL 3+, these functions are no longer available. If you are new to OpenGL, I suggest that you skip learning the old ways and focus on modern, shader-oriented OpenGL. You can check the following links for some good tutorials.

  1. open.gl
  2. opengl-tutorial.org
  3. ogldev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM