【发布时间】:2018-03-26 00:11:58
【问题描述】:
该系统在使用 openGL 2.1 的 pygame、glut 和 glfw 上运行良好,但是一旦我尝试强制使用 openGL 3.2,openGL 立即失败。这是我的 glfw 实现,我也有一个类似风格的 GLUT 程序,它失败并出现相同的错误。
class GlfwDisplayController(object):
def __init__(self,resolution):
glfw.init()
self._resolution = resolution
w,h = self._resolution
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE);
self._window = glfw.create_window(w,h,"GLFW openGL render",None,None)
glfw.make_context_current(self._window)
def kill(self):
glfw.terminate()
def display(self):
glfw.swap_buffers(self._window)
glfw.poll_events()
if __name__ == "__main__":
from OpenGL.GL import *
import glfw
testContext = GlfwDisplayController( (500,500) )
#testing to make sure the context was created
glMatrixMode(GL_MODELVIEW)
这是错误输出。如果我注释掉所有 glfw.window_hint() 调用,这适用于 openGL 2.1
Traceback (most recent call last):
File "src/rendering/Display_controller.py", line 134, in <module>
glMatrixMode(GL_MODELVIEW)
File "/usr/local/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
return self( *args, **named )
File "errorchecker.pyx", line 53, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError (src/errorchecker.c:1218)
OpenGL.error.GLError: GLError(
err = 1282,
description = 'invalid operation',
baseOperation = glMatrixMode,
cArguments = (GL_MODELVIEW,)
)
据我所知,OSX 已全面更新,包括图形驱动程序。在系统中访问 openGL 3.2+ 时我需要做些什么特别的事情吗?我完全厌倦了使用 glsl 1.2 :(
glxinfo 输出:
$ glxinfo | grep openGL
OpenGL vendor string: Intel Inc.
OpenGL renderer string: Intel(R) Iris(TM) Graphics 6100
OpenGL version string: 2.1 INTEL-10.25.17
OpenGL shading language version string: 1.20
OpenGL extensions:
【问题讨论】:
标签: python macos opengl pyopengl