OpenGL: What does glRotatef rotate?

sanjeev mk picture sanjeev mk · Aug 13, 2014 · Viewed 12.1k times · Source

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.

Answer

Sneftel picture Sneftel · Aug 13, 2014

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