OpenGL: What does glRotatef rotate?
Asked Answered
H

2

8

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.

Hallam answered 13/8, 2014 at 18:19 Comment(0)
R
8

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".

Radicel answered 13/8, 2014 at 18:24 Comment(2)
Not only does OpenGL not store objects, it literally has no notion of the concept of objects.Amino
@sanjeevmk The transformation matrix is applied to the vertices you pass in using glVertex.Amino
U
2

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
Urban answered 13/8, 2014 at 18:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.