【发布时间】:2021-03-19 23:30:22
【问题描述】:
我什至无法运行使用 OpenGL / GLUT 的最简单的程序。
即
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
def showScreen():
# Remove everything from screen (i.e. displays all white)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glutInit() # Initialize a glut instance which will allow us to customize our window
glutInitDisplayMode(GLUT_RGBA) # Set the display mode to be colored
glutInitWindowSize(500, 500) # Set the width and height of your window
# Set the position at which this windows should appear
glutInitWindowPosition(0, 0)
wind = glutCreateWindow("OpenGL Coding Practice") # Give your window a title
# Tell OpenGL to call the showScreen method continuously
glutDisplayFunc(showScreen)
# Draw any graphics or shapes in the showScreen function at all times
glutIdleFunc(showScreen)
glutMainLoop()
我总是收到此错误消息:
Traceback (most recent call last):
File "/Users/xyz/jebacglut123.py", line 11, in <module>
glutInit() # Initialize a glut instance which will allow us to customize our window
File "/usr/local/anaconda3/envs/opengl/lib/python3.8/site-packages/OpenGL/GLUT/special.py", line 362, in glutInit
_base_glutInit(ctypes.byref(count), holder)
File "/usr/local/anaconda3/envs/opengl/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 423, in __call__
raise error.NullFunctionError(
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
我正在使用 MacOS Big Sur 20B29、python 3.8.5 和 PyOpenGL 3.1.5。我已使用this 教程修改了 PyOpenGL 文件以修复其他错误。
【问题讨论】:
标签: python macos opengl glut pyopengl