古月今犹在 2016-03-06 05:53 采纳率: 0%
浏览 4596

Python3.5.1 PyopenGL模块调用出错

测试PyopenGL模块的源代码来自网上:

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

def drawFunc():
    glClear(GL_COLOR_BUFFER_BIT)
    #glRotatef(1, 0, 1, 0)
    glutWireTeapot(0.5)
    glFlush()

glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(400, 400)
glutCreateWindow("First")
glutDisplayFunc(drawFunc)
#glutIdleFunc(drawFunc)
glutMainLoop() 

运行错误提示如下:

 ============= RESTART: F:\Python35-32\Code\PyOpenGLCode\Test.py =============
Traceback (most recent call last):
  File "F:\Python35-32\Code\PyOpenGLCode\Test.py", line 11, in <module>
    glutInit()
  File "F:\Python35-32\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "F:\Python35-32\lib\site-packages\OpenGL\platform\baseplatform.py", line 407, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
>>> 
  • 写回答

2条回答 默认 最新

  • oyljerry 2016-03-06 06:55
    关注

    你是否没有调用初始化 看看错误提示

    评论

报告相同问题?