利用opengl绘制图形:
#include <GL/glut.h>
#include <math.h>
const int WindowWidth = 600, WindowHeight = 600;
/************************************************************************/
/* 中点线画圆 */
/************************************************************************/
void CirclePoints(int CenterX, int CenterY, int x, int y)
{
glVertex2i(x + CenterX, y + CenterY);
glVertex2i(y + CenterX, x + CenterY);
glVertex2i(-y + CenterX, x + CenterY);
glVertex2i(-x + CenterX, y + CenterY);
glVertex2i(y + CenterX, -x + CenterY);
glVertex2i(x + CenterX, -y + CenterY);
glVertex2i(-x + CenterX, -y + CenterY);
glVertex2i(-y + CenterX, -x + CenterY);
}
void MidPointCircle(int CenterX, int CenterY, int r)
{
int x = 0;
int y = r;
float d = 1.25 - r;
CirclePoints(CenterX, CenterY, x, y);
while (x < y)
{
x++;
if (d <= 0)
{
d += 2 * x + 3;
}
else
{
d += 2 * (x - y) + 5;
y--;
}
CirclePoints(CenterX, CenterY, x, y);
}
}
/********************