/************************************************************ Add Opengl32.lib glu32.lib glut32.lib to Project->Setting->Link->General->Object/Library Modules. *************************************************************/ // Source: http://www.site.uottawa.ca/~nbobic/csi4130 #include "glut.h" #include #define M_PI (4*atan(1)) /* animation step */ int step; void circle( GLint res, GLfloat radius ){ int i; glBegin(GL_POLYGON); for (i=0;i 1.0) glOrtho(0.0,100.0*ar,0.0,100.0,10.0,-10.0); else glOrtho(0.0,100.0,0.0,100.0/ar,10.0,-10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void animate(int value){ /* stop after 30 steps */ if(value == 30) { // return; value=0; step=0; } glutPostRedisplay(); step++; /* call animate again in 200 mili-Secs */ glutTimerFunc(200,animate,step); } void menuControl(int value){ switch (value){ case 1: /* call animate in 200 mili-Secs */ glutTimerFunc(200,animate,step); break; case 2: step = 0; /* call animate in 200 mili-Secs */ glutTimerFunc(200,animate,step); break; case 101: exit(1); break; } } int main(int argc,char **argv){ glutInit(&argc,argv); /* window definition and creation */ /* the viewport is the same as window coords */ glutInitWindowSize(800,800); glutInitWindowPosition(50,50); glutCreateWindow("Animation: Flickering"); /* the reshape function */ glutReshapeFunc(reshapeWin); /* the display function */ glutDisplayFunc(displayWin); glutCreateMenu(menuControl); glutAddMenuEntry("Start",1); glutAddMenuEntry("Restart",2); glutAddMenuEntry("Exit",101); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; }