问题
I am trying to get 3D capabilities through python and have download pyglet. While going through the first example in this tutorial I got a bunch of strange errors that I cannot discern. The following is the script I am trying to run:
import pyglet
win = pyglet.window.Window()
@win.event
def on_draw():
win.clear()
pyglet.app.run()
2 The following is the output I received from the python interpreter after I imported my script:
>>> import test as t
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 13, in <module>
pyglet.app.run()
File "/usr/lib/pymodules/python2.7/pyglet/app/__init__.py", line 264, in run
EventLoop().run()
File "/usr/lib/pymodules/python2.7/pyglet/app/xlib.py", line 93, in run
sleep_time = self.idle()
Fihttp://greendalecs.wordpress.com/2012/04/21/3d-programming-in-python-part-1/#commentsle "/usr/lib/pymodules/python2.7/pyglet/app/__init__.py", line 193, in idle
window.dispatch_event('on_draw')
File "/usr/lib/pymodules/python2.7/pyglet/window/__init__.py", line 1219, in dispatch_event
EventDispatcher.dispatch_event(self, *args)
File "/usr/lib/pymodules/python2.7/pyglet/event.py", line 340, in dispatch_event
if handler(*args):
File "test.py", line 13, in on_draw
pyglet.app.run()
NameError: global name 'GL_COlOR_BUFFER_BIT' is not defined
- How can I fix these errors? I use Ubuntu 12.04 LTS and Emacs 24.3.
- I have downloaded pyglet, through
apt-get install
but is there anything else I needed to do? Perhaps I do not have drivers configured or I need different software.
If you need more information let me know!
回答1:
GL_COlOR_BUFFER_BIT
is undefined, because the value you are looking for is called GL_CO
LOR_BUFFER_BIT
...
回答2:
For future reference, as of Pyglet 1.1.4, this is because 1.1.4 no longer supports "recent" versions of Mac OS.
However, the most recent non-released version of Pyglet DOES support, with a full new interface using Cocoa. So, until Pyglet 1.2 is released, you have to install Pyglet directly from the trunk, using e.g.
pip install --upgrade http://pyglet.googlecode.com/archive/tip.zip
来源:https://stackoverflow.com/questions/18033227/python-pyglet-and-opengl