glBegin( GL_LINE_STRIP ); // Bottom of Box glVertex3f(-0.5, -0.5, -0.5); glVertex3f(-0.5, -0.5, 0.5); glVertex3f(0.5, -0.5, 0.5); glVertex3f(0.5, -0.5, -0.5); glVertex3f(-0.5, -0.5, -0.5); // Top of Box glVertex3f(-0.5, 0.5, -0.5); glVertex3f(-0.5, 0.5, 0.5); glVertex3f(0.5, 0.5, 0.5); glVertex3f(0.5, 0.5, -0.5); glVertex3f(-0.5, 0.5, -0.5); glEnd();Drawing the sides of the box: - Use GL_LINES to draw each edge.
glBegin( GL_LINES ); // For the Sides of the Box glVertex3f(-0.5, 0.5, -0.5); glVertex3f(-0.5, -0.5, -0.5); glVertex3f(-0.5, -0.5, 0.5); glVertex3f(-0.5, 0.5, 0.5); glVertex3f(0.5, -0.5, 0.5); glVertex3f(0.5, 0.5, 0.5); glVertex3f(0.5, -0.5, -0.5); glVertex3f(0.5, 0.5, -0.5); glEnd();
glPushMatrix(); glRotatef(30.0, 0.0, 0.0, 1.0); glRotatef(20.0, 0.0, 1.0, 0.0); glRotatef(40.0, 1.0, 0.0, 0.0); DrawBox(); glPopMatrix();
No Rotation |
Rotation | Source Code |