openGL绘制圆

const int n = 3;
const GLfloat R = 0.5f;
const GLfloat pi = 3.1415926536f;


void display()
{
	int i = 0;
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_POLYGON);
	for (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(100, 100);
	glutInitWindowSize(400, 400);
	glutCreateWindow("opengl 3d view");
	//init();
	glutDisplayFunc(display);
	glutMainLoop();

	return 0;
}

一、当n = 3, glBegin(GL_POLYGON)时

openGL绘制圆_第1张图片

二、当n = 3, glBegin(GL_LINE_LOOP)时

openGL绘制圆_第2张图片

三、当n = 10, glBegin(GL_LINE_LOOP)时

openGL绘制圆_第3张图片

四、当n = 100, glBegin(GL_LINE_LOOP)时

openGL绘制圆_第4张图片

五、当n = 100, glBegin(GL_POINTS)时

openGL绘制圆_第5张图片

六、当n = 100, glBegin(GL_QUADS)时

openGL绘制圆_第6张图片

六、当n = 100, glBegin(GL_LINE_STRIP)时

openGL绘制圆_第7张图片

你可能感兴趣的:(Qt)