我在win 10 x64上运行spyder(python 3.7)并使用

2024-03-28 15:31:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在Win10 x64上运行spyder(python 3.7) 使用

pip install PyOpenGL PyOpenGL_accelerate

在Anaconda命令行上安装PyOpenGL

import sys,os
from OpenGL.GLUT import *
from OpenGL.GL import *
from OpenGL.GLU import *
def draw():
    glClear(GL_COLOR_BUFFER_BIT)
    glutWireTeapot(0.5)
    glFlush()

glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(250, 250)
glutInitWindowPosition(100, 100)
glutCreateWindow("My Second OGL Program")
glutDisplayFunc(draw)
glutMainLoop()

我有这个错误


  File "<ipython-input-12-369d79eca146>", line 12, in <module>
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)

  File "C:\Users\Gold\Anaconda3\lib\OpenGL\platform\baseplatform.py", line 425, in __call__
    self.__name__, self.__name__,

NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling

Tags: infromimportsyslinergbcallfile