iDevGames Forums
OpenGL: glRotate and some 3D questions. - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: OpenGL: glRotate and some 3D questions. (/thread-1272.html)

OpenGL: glRotate and some 3D questions. - mikey - May 19, 2009 12:59 PM

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
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?

OpenGL: glRotate and some 3D questions. - ThemsAllTook - May 19, 2009 05:11 PM

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.