OpenGL: glRotate and some 3D questions.

Member
Posts: 281
Joined: 2009.04
Post: #1
I've been reading NeHe's OpenGL tutorials, and I don't understand glRotate. I see how it works, but how does one take glRotate and apply it to the plane? I mean, the plane in NeHe's work's coordinate's are just
Code:
```glVertex3f(-1.0f, 1.0f, 0.0f);            // Top Left Of The Quad         glVertex3f( 1.0f, 1.0f, 0.0f);            // Top Right Of The Quad         glVertex3f( 1.0f,-1.0f, 0.0f);            // Bottom Right Of The Quad         glVertex3f(-1.0f,-1.0f, 0.0f);```

I don't see any rotated variables? And where's the connection between rquad and the Quad's coords?

PS. It looks as if NeHe is using predefined perspective algorithms. Where do they affect the shapes?

~ Bring a Pen ~
Moderator
Posts: 1,563
Joined: 2003.10
Post: #2
OpenGL is stateful. Things like the current matrix transformation are kept track of internally. When you call a function like glRotate, you're performing an operation that modifies the current transformation matrix. When you call glVertex, the coordinates you specify are multiplied by the projection and modelview matrices before being rasterized.

The above is a very simplified explanation; the OpenGL Red book (an old version is available online) explains all of this in greater detail than I'd be able to. I'd highly recommend it as a learning resource.