/****************************************************** ** Demo Program for glGetError ** Intentially causes an error. ** ** R.S. Dannelly *****************************************************/ #include #include /********************************************************/ void display(void) { GLenum errcode; // var for error code number glClearColor (0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glColor3f (1.0, 0.5, 0.6); glRotatef (45.0, 1,1,1); glTranslatef (20,20,0); glutSolidDodecahedron (); glPopMatrix(); glPopMatrix(); // error glColor3f (1.9, -0.5, -0.6); // not an error? glTranslatef (-20,-20,0); glScalef (5,5,5); glutWireDodecahedron (); glFlush(); while ((errcode = glGetError()) != GL_NO_ERROR) printf("OpenGL Error: %s\n", gluErrorString(errcode)); } /********************************************************/ void reshape(int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-50.0, 50.0, -50.0, 50.0, -50.0, 50.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } /****** exit on mouse click **************************/ void mouse(int button, int state, int x, int y) { if (state == GLUT_DOWN) exit(1); } /********************************************************/ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_RGB); glutInitWindowSize (450, 450); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutMainLoop(); return 0; }