L01man
L01man

Reputation: 1523

Pyglet: Sprite.draw() and Batch.draw() don't work, but Image.blit does

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.

Upvotes: 0

Views: 1518

Answers (1)

L01man
L01man

Reputation: 1523

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.

Upvotes: 1

Related Questions