2 u013166622 u013166622 于 2016.03.06 13:53 提问

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个回答

u013166622
u013166622   2016.03.08 23:03
oyljerry
oyljerry   Ds   Rxr 2016.03.06 14:55

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!