首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pyglet和PIL: glError

Pyglet和PIL: glError
EN

Stack Overflow用户
提问于 2017-02-02 09:13:33
回答 1查看 176关注 0票数 0

我想知道为什么我能得到这个错误:

代码语言:javascript
复制
pyglet.lib.gl.GLExeption: invalid value
at: self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())

进口libs:

代码语言:javascript
复制
import sys
import math
import random
import time
from collections import deque
from pyglet import image
from pyglet.gl import *
from pyglet.graphics import TextureGroup
from pyglet.window import key, mouse, Window
from PIL import Image

我用PIL制作PNG:

代码语言:javascript
复制
print "Creating ", TEXTURE_PATH
images = map(Image.open, texture_path)
widths, heights = zip(*(i.size for i in images))

total_width = sum(widths)
max_height = max(heights)

new_im = Image.new('RGB', (total_width, max_height))

x_offset = 0
for im in images:
    new_im.paste(im, (x_offset,0))
    x_offset += im.size[0]
new_im.convert('RGB')
new_im.save(TEXTURE_PATH, "PNG")

而‘texture_path`(小写)在这里:

代码语言:javascript
复制
texture_path = ['res/textures/grass_top.png'] * 99

完整的错误消息是:

代码语言:javascript
复制
Traceback (most recent call last):
  File "D:\pythoncode\pyglet\minecraft_remake.py", line 955, in <module>
    main()
  File "D:\pythoncode\pyglet\minecraft_remake.py", line 948, in main
    window = Window(width = 640, height = 480, caption="Minecraft 3d!", resizable=True)
  File "D:\pythoncode\pyglet\minecraft_remake.py", line 554, in __init__
    self.model = Model()
  File "D:\pythoncode\pyglet\minecraft_remake.py", line 198, in __init__
    self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())
  File "C:\Python27\lib\site-packages\pyglet\image\__init__.py", line 818, in get_texture
    force_rectangle)
  File "C:\Python27\lib\site-packages\pyglet\image\__init__.py", line 803, in create_texture
    rectangle, force_rectangle)
  File "C:\Python27\lib\site-packages\pyglet\image\__init__.py", line 1514, in create
    blank)
  File "C:\Python27\lib\site-packages\pyglet\gl\lib.py", line 104, in errcheck
    raise GLException(msg)
GLException: invalid value

我发现了问题,但不知道如何解决,问题是在巴布亚新几内亚制造的。

当我用另一张图片替换textures.png时,它是工作的,但是当我用PIL制作一个时,它就不起作用了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-07 08:32:26

问题解决了:问题在我的.PNG编辑器中,我只需手动制作图像,它就能工作了!

我使用图形狂风免费版来编辑和它将工作。

我认为问题在于PIL本身。或者pyglet不加载PIL配置PNG

这可能是因为颜色的配置

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41998201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档