发布时间:2019-09-01 10:53:50编辑:auto阅读(2120)
参考:http://pyopengl.sourceforge.net
一、pip 安装 PyOpenGL
pip install PyOpenGL PyOpenGL_accelerate
二、测试代码
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
def init():
glClearColor(1,1,1,1)
gluOrtho2D(-1,1,-1,1)
def triangle():
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1,0,0)
glBegin(GL_TRIANGLES)
glColor3f(1,0,0)
glVertex2f(-1, -1)
glColor3f(0,1,0)
glVertex2f(1, -1)
glColor3f(0,0,1)
glVertex2f(0, 1)
glEnd()
glFlush()
def main():
glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(800,600)
glutInitWindowPosition(50,50)
glutCreateWindow("Triangle")
glutDisplayFunc(triangle)
init()
glutMainLoop()
if __name__ == '__main__':
main()
上一篇: python except
下一篇: python_笔记3_list列表(有序
47868
46434
37321
34767
29337
25999
24952
19970
19568
18056
5811°
6436°
5953°
5979°
7083°
5929°
5970°
6462°
6427°
7804°