无法在pyglet中绘制()精灵 [英] Can't draw() sprites in pyglet
问题描述
由于某种原因,我无法让pyglet绘制精灵。这是我的代码:
For some reason, I can't get pyglet to draw sprites. Here's my code:
import pyglet
game = pyglet.window.Window(640, 480, "I'm a window")
batch = pyglet.graphics.Batch()
pyglet.resource.path = ["."]
pyglet.resource.reindex()
image = pyglet.resource.image("hextile.png")
pyglet.sprite.Sprite(image, x=200, y=300, batch=batch)
pyglet.text.Label('DING', font_name='Arial', font_size=24, x=100, y=100, batch=batch)
@game.event
def on_draw():
game.clear()
batch.draw()
#image.blit(0, 0)
pyglet.app.run()
现在,当我绘制批处理时,将显示文本标签正确地。我在窗口上看到丁。但是,未显示图像 hextile.png。我尝试独立绘制精灵,但这也不起作用。但是,略过图像(如注释行所示)似乎还可以,但显然这并不是我想要的功能。我无法弄清楚这一点。我缺少什么?
Now, when I draw the batch, the text label is shown correctly. I see "DING" on the window. However, the image "hextile.png" is not shown. I tried drawing the sprite independently, but that didn't work either. Blitting the image (as shown in the commented line), however, seems to work just fine, but obviously that's not quite the functionality I'm after here. I can't figure this one out. What am I missing?
推荐答案
假设您和您的朋友有ATI图形卡:
Sprite.draw()内部使用 v2i
格式和VertexDomain.draw()。由于某种原因,此组合不适用于Windows Vista / 7 Catalyst 11.9及更高版本的驱动程序,因此Sprite绘制也将失败。另请参见: pyglet顶点列表未呈现(AMD驱动程序?)
Sprite.draw() uses the v2i
format and VertexDomain.draw() internally. For some reason this combination doesn't work on Windows Vista/7 Catalyst drivers 11.9 and above, and consequently Sprite drawing fails as well. See also: pyglet vertex list not rendered (AMD driver?)
您可能需要遵循pyglet问题: http://code.google.com/p/pyglet/issues/detail?id=544
There is a pyglet issue you might want to follow: http://code.google.com/p/pyglet/issues/detail?id=544
您的如对该问题的第三条评论或降级您的视频驱动程序。
Your options for the moment seem to be either to patch pyglet.sprite.Sprite as mentioned in the third comment on that issue or downgrade your video driver.
更新:无需修补Sprite或降级您的视频驱动程序。这个问题似乎已在Catalyst 12.4(视频驱动程序8.961.0.0)中解决。
Update: No need to patch Sprite or downgrade your video driver. This problem seems to be fixed with Catalyst 12.4 (video driver 8.961.0.0).
这篇关于无法在pyglet中绘制()精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!