我正在尝试为Pyglet运行以下测试代码:
import pyglet
pyglet.options['shadow_window'] = False
# Specify the OpenGL version explicitly to request 3.0 features, including
# GLSL 1.3.
# Enable depth buffer and double buffering as well
config = pyglet.gl.Config(double_buffer = True,
depth_size = 24,
major_version=3,
minor_version=2,
forward_compatible = True)
# Create a context matching the above configuration. Will fail if
# OpenGL 3 is not supported by the driver.
window = pyglet.window.Window(config=config, visible=False)
# Print the version of the context created.
print('OpenGL version:', window.context.get_info().get_version())
print('OpenGL 3.2 support:', window.context.get_info().have_version(3, 2))
window.close()
但是,我收到错误
Traceback (most recent call last):
File "C:\Users\dwill\Downloads\test (1)\pyglet_ogl3.py", line 16, in <module>
window = pyglet.window.Window(config=config, visible=False)
File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 131, in __init__
super(Win32Window, self).__init__(*args, **kwargs)
File "C:\Python27\lib\site-packages\pyglet\window\__init__.py", line 559, in __init__
self._create()
File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 261, in _create
self.context.attach(self.canvas)
File "C:\Python27\lib\site-packages\pyglet\gl\win32.py", line 198, in attach
'OpenGL 3 contexts.')
ContextException: Require WGL_ARB_create_context extension to create OpenGL 3 contexts.
我的硬件是带有最新驱动程序的NVIDIA 650M。 pyglet目录中的测试文件确实成功运行。