<img src="https://img-blog.csdn.net/20141009140700955?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMjAxMjEzMzc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" height="275" align="bottom" border="1" hspace="1" vspace="1" width="298" alt="" />
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int i,x;
const int n = 100;
const GLfloat R = 0.5f;
const GLfloat Pi = 3.1415926536f;
const GLfloat factor = 0.1f;
void draw(){
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(1.0f);
glColor3f(1.0f,1.0f,1.0f);
for(i=0; i<x; i++){
for(int j=0;j<x;j++){
glBegin(GL_LINE_LOOP);
glVertex2f(cos(((i)*(360/x))*Pi/180),sin(((i)*(360/x))*Pi/180));
glVertex2f(cos(((j)*(360/x))*Pi/180),sin(((j)*(360/x))*Pi/180));
glEnd();
glFlush();
}
}
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
printf("请输入要画的点数 \n");
scanf("%d",&x);
glutCreateWindow("多边形");
glutDisplayFunc(&draw);
glutMainLoop();
return 0;
}
opengl绘制花环(点的个数可以手动输入) c 实现代码
最新推荐文章于 2020-02-16 21:53:12 发布