Pyglet 和 PIL:glError
Pyglet and PIL: glError
我想知道为什么我会得到这个错误:
pyglet.lib.gl.GLExeption: invalid value
at: self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())
导入的库:
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:
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`(小写)在这里:
texture_path = ['res/textures/grass_top.png'] * 99
完整的错误信息是:
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
我发现了问题,但不知道如何解决,问题出在 PNG 制作上。
当我用另一张图片替换 textures.png 时,它起作用了
但是当我用PIL做一个时,它不起作用。
已解决:问题出在我的 .PNG 编辑器中,我只是手动制作图像并且它有效!
我正在使用 Graphics Gale 免费版进行编辑,它可以工作。
我认为问题出在 PIL 本身。或者 pyglet 不加载 PIL 配置 PNG
P.s可能是因为颜色配置
我想知道为什么我会得到这个错误:
pyglet.lib.gl.GLExeption: invalid value
at: self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())
导入的库:
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:
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`(小写)在这里:
texture_path = ['res/textures/grass_top.png'] * 99
完整的错误信息是:
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
我发现了问题,但不知道如何解决,问题出在 PNG 制作上。
当我用另一张图片替换 textures.png 时,它起作用了 但是当我用PIL做一个时,它不起作用。
已解决:问题出在我的 .PNG 编辑器中,我只是手动制作图像并且它有效!
我正在使用 Graphics Gale 免费版进行编辑,它可以工作。
我认为问题出在 PIL 本身。或者 pyglet 不加载 PIL 配置 PNG
P.s可能是因为颜色配置