void drawCircle(float radius, int points, Vec2d center){
Vec2d cp; //circle points as vector
for (int i = 0; i<points; i++){
float angle = ((2*PI)/points)*i; //2*pi is 360 divided into degree segments based on points multiplied by what point your on
cp.x= cos(angle) * radius; //gets the length of x and muiltiplies by stretch
cp.y= sin(angle) * radius; //gets the length of y and muiltiplies by stretch
cp = cp+center; //sets the offset center point
//cp.x += 300; //adds in the of set
//cp.y += 300; //adds in the of set
glVertex2f(cp.x,cp.y);
}
}
void displayFunc ( void ) //arg void returns void
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );//clears buffers(what buffers?) by setting bit mask or.
glColor3f( 1,0,0 );//sets color can add a alpha on end 255,255,255,255
//glRectf( mouseX-rectSize, mouseY-rectSize, mouseX+rectSize, mouseY+rectSize); //two arguments cords of perp corners this case based on mouse
Vec2d a(200,500);// vector line
Vec2d b(230,500);// vector line
Vec2d c(280,500);// vector line
Vec2d d(350,500);// vector line
Vec2d e(440,500);// vector line
// place your drawing code here
//circles
glBegin(GL_LINE_LOOP);
drawCircle( 10.0, 30, a); //draw circle
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 20.0, 30, b);
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 30.0, 30, c);
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 40.0, 30, d); //draw circle
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 30, e);
glEnd( );
//polygons
Vec2d f(200,300);// vector line
Vec2d g(230,300);// vector line
Vec2d h(280,300);// vector line
Vec2d i(350,300);// vector line
Vec2d j(440,300);// vector line
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 3, f); //draw circle
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 4, g);
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 5, h);
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 6, i); //draw circle
glEnd( );
glBegin(GL_LINE_LOOP);
drawCircle( 50.0, 7, j);
glEnd( );
glutPostRedisplay(); //tags the current window to be redisplayed or shown through the
//next iteration loop.
glutSwapBuffers(); //calls for the display of a the current buffer for the curretn window
// i assume to cut down on jerky motion
}