#include <glut.h>
#include <math.h>
const int n = 20;
const GLfloat R = 0.5f;
const GLfloat Pi = 3.1415926536f;
void myDisplay(void) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
for (int i = 0; i<n; ++i)
glVertex2f(R*cos(2 * Pi / n*i), R*sin(2 * Pi / n*i));
glEnd();
glFlush();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(10, 10);
glutInitWindowSize(400, 400);
glutCreateWindow("the first opengl program");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}
画一个圆形

最新推荐文章于 2021-10-31 15:44:13 发布