0

In pyglet, which I'm learning, Image.blit() works, but Sprite.draw() doesn't, nor Batch.draw(), even in this simple code:

import pyglet

win = pyglet.window.Window()

img = pyglet.resource.image('test.png')
spr = pyglet.sprite.Sprite(img)

@win.event
def on_draw():
    win.clear()
    spr.draw()


if __name__ == '__main__':
    pyglet.app.run()

The window remains black. However, I can draw labels, for example. THe only explaination I found was about graphic cards and "v2i" bugs with some of them, but I'm afraid to touch at pyglet's code without really knowing what I'm doing.

L01man
  • 1,521
  • 10
  • 27
  • 1
    I don't know much about your issue, but there's another simple Python graphics framework you could use called [Pygrafix](https://github.com/nightcracker/Pygrafix) which might work for you – Andrea Apr 22 '12 at 14:31
  • Thank you for the link. The API reminds pyglet, even though it's not as "Pythonic". If I really don't get any solutions, I'll consider using it, but I would like to avoid compiling Cython and Pygrafix from source since I'm on Ubuntu. – L01man Apr 22 '12 at 14:45
  • It's developed on Linux, I believe it's much easier to compile on Ubuntu than on Mac OS X. – Andrea Apr 22 '12 at 14:49
  • I agree. I'll do it if there is no other solution. However, since Pygrafix is not really known, the doc' and the tutorials are very limited. – L01man Apr 22 '12 at 16:53
  • Yeah, I'll admit it has that problem. The docs are [here](http://readthedocs.org/docs/pygrafix/en/latest/), although they are lacking a bit in detail. – Andrea Apr 22 '12 at 21:33
  • Until I fix the pyglet issue I'll go with Pygame. About Pygrafix, I wonder if there only purpose was to write a game lib in Cython since I find its and pyglet's API very, very similar. – L01man Apr 23 '12 at 00:46
  • Well... I know the guy who made it (I work on the project it was basically made for), it was designed to be hardware-accelerated and for high performance. He didn't like pyglet because you need to use ctypes for it, I think. – Andrea Apr 23 '12 at 17:31
  • Then, it's just a different implementation of the Pyglet API? In this case, there is indeed no need for extra tutorials other than those for Pyglet. – L01man Apr 27 '12 at 07:49
  • I'm not sure. It does look quite similar although I believe there are some differences. It's not a difficult API to use though, doubt you'd really need tutorials. – Andrea Apr 27 '12 at 15:03

1 Answers1

1

The third answer of this thread worked for me, even though I'm using Ubuntu and not Windows. It's actually a hardware problem. I replaced the "i" with the "f" at lines 368 and 372 in "v2i" in a file I found at /usr/lib/pymodules/python2.7/pyglet/sprite.py. Then I saved, ran my code, and everything was working.

Community
  • 1
  • 1
L01man
  • 1,521
  • 10
  • 27
  • It was actually a driver problem which seems to be fixed in Catalyst 12.4. So no more need to patch sprite.py! – Eric May 12 '12 at 21:17