1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<GL/glut.h>
#include<math.h>
void init ( void ){
     glClearColor ( 1.0, 1.0, 1.0, 0.0 );
     glMatrixMode ( GL_PROJECTION );
     gluOrtho2D ( 0.0, 100.0, 0.0, 100.0 );
}

/*void Circle(int x,int y)
{
    int n=30;
	GLfloat radius = 15;  
	GLfloat Pi = 3.1415926536f;
	 
	 glBegin(GL_LINE_LOOP);
     for(int i=0; i<n; ++i){ 
     	glVertex2f(x+radius*cos((2*Pi/n*i)+(Pi/10)),y+radius*sin((2*Pi/n*i)+(Pi/10)));
       
        
     } 
     glEnd();
     
     glFlush();
}*/
void poly(int x,int y)
{
    int n=12;
	GLfloat radius = 15;  
	GLfloat Pi = 3.1415926536f;
	 
	 glBegin(GL_LINE_LOOP);
     for(int i=0; i<n; ++i){ 
     	glVertex2f(x+radius*cos((2*Pi/n*i)+(Pi/10)),y+radius*sin((2*Pi/n*i)+(Pi/10)));
        //glEnd();
        //Circle(x+radius*cos((2*Pi/n*i)+(Pi/10)),y+radius*sin((2*Pi/n*i)+(Pi/10)));
        
     } 
     glEnd();
     
     glFlush();
}



void DrawCircle(void)
{
     glClear(GL_COLOR_BUFFER_BIT);
     glColor3f(0.0,0.0,0.0);	//正五邊形 
     poly(50,50);


     

     
     
     glFlush();
}




int main ( int argc, char**argv ){
    glutInit ( &argc, argv );
    glutInitWindowSize(500,500);
    glutInitWindowPosition(50,100);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
    glutCreateWindow("B0329029_4");
    
    init ();

    glutDisplayFunc (DrawCircle);
    glutMainLoop ();
}