OpenGL-绘制一个圆

import math

from OpenGL.GL import *
from OpenGL.GLUT import *


def myDisplay():

    glClear(GL_COLOR_BUFFER_BIT)
    glBegin(GL_POLYGON)

    n=200
    R=0.5
    pi= math.pi
    for i in range (n):
        glVertex2f(R*math.cos(2*pi/n*i),R*math.sin(2*pi/n*i))
    glEnd();
    glFlush();


glutInit();
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("Test");
glutDisplayFunc(myDisplay);
glutMainLoop();

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u014723479/article/details/128585593