首先给出R、r和Pi的值:
const GLfloat R = 0.5f;
const GLfloat r = 0.2f;
const GLfloat Pi = 3.1415926536f;
GLfloat GetPointCos(GLfloat R, int angle) {
return (R*cos(angle * Pi / 180));
}
GLfloat GetPointSin(GLfloat R, int angle) {
return (R*sin(angle * Pi / 180));
}
GLfloat pointA[2] = { 0, R };
GLfloat pointB[2] = { GetPointCos(R, 18), GetPointSin(R, 18) };
GLfloat pointC[2] = { GetPointCos(R, 54), -GetPointSin(R, 54) };
GLfloat pointD[2] = { -GetPointCos(R, 54), -GetPointSin(R, 54) };
GLfloat pointE[2] = { -GetPointCos(R, 18), GetPointSin(R, 18) };
GLfloat pointa[2] = { 0, -r };
GLfloat pointb[2] = { -GetPointCos(r, 18), -GetPointSin(r, 18) };
GLfloat pointc[2] = { -GetPointCos(r, 54), GetPointSin(r, 54) };
GLfloat pointd[2] = { GetPointCos(r, 54), GetPointSin(r, 54) };
GLfloat pointe[2] = { GetPointCos(r, 18), -GetPointSin(r, 18) };
glBegin(GL_LINE_LOOP);
glVertex2fv(pointA);
glVertex2fv(pointd);
glVertex2fv(pointB);
glVertex2fv(pointe);
glVertex2fv(pointC);
glVertex2fv(pointa);
glVertex2fv(pointD);
glVertex2fv(pointb);
glVertex2fv(pointE);
glVertex2fv(pointc);
glEnd();
好吧,第一次的博客就写到这里了,写这些的初衷只是为了记录自己学习的过程,也为了能在网上和大家共同交流共同学习,可能有些地方描述的还不够详细,或者方法不够简洁,以后会更加努力的,谢谢大家支持!