OpenGL绘制圆弧/圆/饼图 2 //rorger,2011 //contact me: jhcyd112@163.com //in this new version, we can both draw a arc/circle/pi with color filled or not. #include "windows.h" #include "glut.h" #include "math.h" #define width 640 #define height 480 void drawArc(double x,double y,double start_angle,double end_angle,double delta_angle,double radius,bool fill) { if (fill) { glBegin(GL_TRIANGLE_FAN); } else { glBegin(GL_LINE_STRIP); } for (double i=start_angle;i<=end_angle;i+=delta_angle) { double vx=x+radius * cos(i); double vy=y+radius*sin(i); glVertex2d(vx,vy); } glEnd(); } void drawCircle(double x, double y, double radius,bool fill) { double pi=acos(-1.0); drawArc(x,y,0,2*pi,pi/180,radius,fill); } void drawPie(double x,double y,double start_angle,double end_angle,double delta_angle,double radius,bool fill) {