/* Demonstration of aliasing Written by Caroline Geiersbach and Scott D. Anderson scott.anderson@acm.org Summer 2003 */ #include #include #include int ObjectID = 1; // start with the teapot void drawScene() { twColorName(TW_CYAN); switch (ObjectID) { case 1: glutSolidTeapot(1); break; case 2: glutWireCube(2); break; case 3: glutSolidCube(2); break; case 4: glutSolidSphere(1,25,25); break; } } void display(void) { twDisplayInit(0,0,0); twCamera(); drawScene(); glFlush(); glutSwapBuffers(); } const int NumFrames = 4; // For anti-aliasing by jittering scene location void displayN(void) { glClearAccum(0,0,0,0); glClear(GL_ACCUM_BUFFER_BIT); for(int frame=0; frame '0' && k < '9') ObjectID = k-'0'; if(k=='a') { AntiAlias = !AntiAlias; if(AntiAlias) glutDisplayFunc(displayN); else glutDisplayFunc(display); } glutPostRedisplay(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH); twInitWindowSize(600,600); glutCreateWindow(argv[0]); glutDisplayFunc(display); twBoundingBox(-2,2,-1,1,-1,1); twMainInit(); twKeyCallback('a',keys,"toggle anti-aliasing"); twKeyCallback('1',keys,"show the teapot"); twKeyCallback('2',keys,"show the wire cube"); twKeyCallback('3',keys,"show the solid cube"); twKeyCallback('4',keys,"show the solid sphere"); glutMainLoop(); return 0; }