pyglet 精灵/纹理问题:从左下角拉伸

发布于 2024-10-06 10:18:57 字数 744 浏览 0 评论 0原文

我的一台笔记本上的 pyglet 出现问题。我正在开发一个相对复杂的 2D 游戏,但即使使用您可以想象的最简约的 pyglet 应用程序,它也会发生:

import pyglet

if __name__ == '__main__':
    window = pyglet.window.Window(width=100, height=100)
    window.clear()

    ball_img = pyglet.image.load('ball.gif')
    ball = pyglet.sprite.Sprite(ball_img)

    @window.event
    def on_draw():
        ball.draw()

    pyglet.app.run()

它应该显示像这样的球的图像:

预期结果,一个球

但它绘制的是一个不知何故拉伸的图像:

实际结果,拉伸球

如果我用 ball_img.blit(0, 0, 0) 替换 ball.draw() ,它会按预期渲染。

该笔记本是运行Linux(英特尔集成显卡)的小型Thinkpad X40。

这种行为是如何引起的或者可能是什么引起的?

I have a problem with pyglet on one of my notebooks. I'm working on a relatively complex 2D-Game but it occurs even with the most minimalistic pyglet application you can imagine:

import pyglet

if __name__ == '__main__':
    window = pyglet.window.Window(width=100, height=100)
    window.clear()

    ball_img = pyglet.image.load('ball.gif')
    ball = pyglet.sprite.Sprite(ball_img)

    @window.event
    def on_draw():
        ball.draw()

    pyglet.app.run()

It should display an image of a ball like this:

Expected result, a ball

But what it's drawing is a somehow stretched image:

Actual result, stretched ball

If I replace ball.draw() with ball_img.blit(0, 0, 0) it gets rendered as expected.

The notebook is a small Thinkpad X40 running Linux (Intel integrated graphics).

How can such a behaviour be caused or what is likely to be causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤星 2024-10-13 10:18:57

在我的笔记本电脑(带有 Intel GMA 4500 的 Ubuntu 10.10)上,您的代码一切正常。我只是修改了图像名称,并使用了计算机上已有的 png。

On my laptop (Ubuntu 10.10 with Intel GMA 4500) everything works fine with your code. I just modified the image name and I used a png that I already had on the computer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文