#include #include #include #include #include #include using namespace std; int AXIS_INDEX[] = {0,1,2,3,4,5}; float XRot, YRot, ZRot; struct VertexL { GLuint * verticies; int size; }; GLfloat * Points; vector Verticies; int Point_Count; void DoErrorReport() { GLenum err = GL_NO_ERROR; while ((err = glGetError()) != GL_NO_ERROR) { cout << "Got error " << err << endl; } } void display() { int i; glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // draw the axis glColor3f(0.0, 0.0, 0.0); glBegin(GL_LINES); glVertex3f(-1,0,0); glVertex3f(1,0,0); glVertex3f(0,-1,0); glVertex3f(0,1,0); glVertex3f(0,0,-1); glVertex3f(0,0,1); glEnd(); glRotatef(XRot, 1,0,0); glRotatef(YRot, 0,1,0); glRotatef(ZRot, 0,0,1); glColor3f(1.0, 0, 0); for(i=0;i> Point_Count; Points = new GLfloat[Point_Count*3]; for(i=0;i> Points[i]; if (i==0) { max = Points[i]; min = Points[i]; } else { if (max < Points[i]) { max = Points[i]; } if (min > Points[i]) { min = Points[i]; } } } // center and scale everything. for(i=0;i> vertex; while (data) { tmp.verticies = new GLuint[vertex]; tmp.size = vertex; for(j=0;j> tmp.verticies[j]; } Verticies.push_back(tmp); data >> vertex; } data.close(); return; } void resize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.5, 1.5, -1.5, 1.5, 1.5, -1.5); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return; } void keyInput(unsigned char key, int x, int y) { switch(key) { case 'x': XRot += 10; break; case 'y': YRot += 10; break; case 'z': ZRot += 10; break; case 27: case 'q': exit(0); break; default: break; } glutPostRedisplay(); return; } int main(int argc, char * argv[]) { string FileName = "cube.off"; if (argc > 1) { FileName = argv[1]; } ReadOff(FileName); glutInit(&argc, argv); glutInitContextVersion(3, 0); glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize(500, 500); glutCreateWindow("Vertex Arrays"); glutDisplayFunc(display); glutReshapeFunc(resize); glutKeyboardFunc(keyInput); glewExperimental = GL_TRUE; glewInit(); setup(); glutMainLoop(); }