/* * main.cpp * CompFormApp * */ #include "Shape.h" float mouseX = 0; float mouseY = 0; int windowW = 800; int windowH = 600; #define PI 3.14159265358979 void drawCircle(float radius, int numOfPts, Vec2d center){ Circle circ(radius, numOfPts, center); circ.draw(); } void displayFunc ( void ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor3f( 1,0,0 ); glRectf( mouseX-5, mouseY-5, mouseX+5, mouseY+5 ); // place your drawing code here Vec2d center(0,250); int vector = 0; for(int i = 10; i <= 50; i = i + 10){ center.x = i + vector; drawCircle(i,30,center); vector = i*2 + vector; } for(int i = 3; i <= 8; i++){ center.x += 50 * 2; drawCircle(50, i, center); vector = 50 + vector; } glutPostRedisplay(); glutSwapBuffers(); } void reshapeFunc ( int w, int h ) { windowW = w; windowH = h; glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluOrtho2D( 0,w,0,h ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } void mouseDownFunc ( int button, int state, int x, int y ) { mouseX = x; mouseY = windowH - y; } void mouseMoveFunc ( int x, int y ) { mouseX = x; mouseY = windowH - y; } void mouseDragFunc ( int x, int y ) { mouseX = x; mouseY = windowH - y; } void keyboardFunc ( unsigned char key, int x, int y ) { } void arrowKeyFunc ( int a_keys, int x, int y ) { } void init ( GLvoid ) { glShadeModel( GL_SMOOTH ); glClearColor( 1.0, 1.0, 1.0, 1.0 ); glEnable ( GL_COLOR_MATERIAL ); glEnable( GL_BLEND ); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } int main ( int argc, char** argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE ); glutInitWindowSize( windowW, windowH ); glutCreateWindow( "a2p2" ); glutDisplayFunc( displayFunc ); glutReshapeFunc( reshapeFunc ); glutMouseFunc( mouseDownFunc ); glutMotionFunc( mouseDragFunc ); glutPassiveMotionFunc( mouseMoveFunc ); glutKeyboardFunc( keyboardFunc ); glutSpecialFunc( arrowKeyFunc ); init(); glutMainLoop( ); return 0; }