| |||||||||||
|
Main Menu Other |
Tutorials -- Drawing and Coloring Primitives | ||||||||||
|
Drawing a 3D PrimitiveNow we'll turn our flat triangle into a pyramid shape. Take out the lines that drew the previous polygon (but keep the glTranslate and glRotate lines). Then copy and paste these lines in. Then move on to the next page. glBegin(GL_POLYGON); glNormal3f( 1, 0, 0); // top vertex glColor4f(1, 0, 0, 1); glVertex3f( 0, 1, 0); // bottom left vertex glColor4f(0, 1, 0, 1); glVertex3f(-1, -1, 1); // bottom right vertex glColor4f(0, 0, 1, 1); glVertex3f( 1, -1, 1); glEnd(); glBegin(GL_POLYGON); glNormal3f( 1, 0, 0); // top vertex glColor4f(1, 0, 0, 1); glVertex3f( 0, 1, 0); // bottom left vertex glColor4f(0, 1, 0, 1); glVertex3f( 1, -1, -1); // bottom right vertex glColor4f(0, 0, 1, 1); glVertex3f( 1, -1, 1); glEnd(); glBegin(GL_POLYGON); glNormal3f( 1, 0, 0); // top vertex glColor4f(1, 0, 0, 1); glVertex3f( 0, 1, 0); // bottom left vertex glColor4f(0, 1, 0, 1); glVertex3f( 1, -1, -1); // bottom right vertex glColor4f(0, 0, 1, 1); glVertex3f(-1, -1, -1); glEnd(); glBegin(GL_POLYGON); glNormal3f( 1, 0, 0); // top vertex glColor4f(1, 0, 0, 1); glVertex3f( 0, 1, 0); // bottom left vertex glColor4f(0, 1, 0, 1); glVertex3f(-1, -1, 1); // bottom right vertex glColor4f(0, 0, 1, 1); glVertex3f(-1, -1, -1); glEnd(); // bottom square polygon glBegin(GL_POLYGON); glNormal3f( 1, 0, 0); glColor4f(0, 0, 1, 1); glVertex3f( 1, -1, 1); glColor4f(0, 1, 0, 1); glVertex3f(-1, -1, 1); glColor4f(0, 0, 1, 1); glVertex3f(-1, -1, -1); glColor4f(0, 1, 0, 1); glVertex3f( 1, -1, -1); glEnd(); Move on to the next page to continue.
|
|||||||||||