#include void display(void) { int i; GLdouble vertex[8][3] = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { 1.0, 0.0, 1.0 }, { 1.0, 1.0, 1.0 }, { 0.0, 1.0, 1.0 } }; int edge[12][2] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } }; glClear(GL_COLOR_BUFFER_BIT); glColor3d(0.0, 0.0, 0.0); glBegin(GL_LINES); for (i = 0; i < 12; i++) { glVertex3dv(vertex[edge[i][0]]); glVertex3dv(vertex[edge[i][1]]); } glEnd(); } void keyboard(unsigned char key, int x, int y) { if (key == '\033') exit(0); } void resize(int w, int h) { glViewport(0, 0, w, h); glLoadIdentity(); /* 1 */ glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0); /* 2 *//* gluPerspective(30.0, 1.0, 1.0, 10.0); glTranslated(0.0, 0.0, -5.0); glRotated(5.0, 1.0, 1.0, 0.0); *//* 3 *//* gluPerspective(30.0, 1.0, 1.0, 10.0); gluLookAt(3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); */ } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutCreateWindow(argv[0]); glClearColor(1.0, 1.0, 1.0, 0.0); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutReshapeFunc(resize); glutMainLoop(); return 0; }