Han Programer Han Programer - 4 years ago 136
Python Question

solved - Pyglet and PIL: glError

Solved: the problem is in my .PNG Editor, i just make the image manually and it works!



I am wondering why I can get this error:

pyglet.lib.gl.GLExeption: invalid value
at: self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())


Imported libs:

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


I'm using PIL for making the 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")


And the 'texture_path`(lowercase) is here:

texture_path = ['res/textures/grass_top.png'] * 99


Any help?

EDIT:
The FULL error Message is:

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


EDIT 2:
i found the problem, but didn't know how to fix it :(
the problem are in the PNG making.

when i replace the textures.png with another picture, its working
but when i make one with PIL, it doesn't work

Answer Source

Solved: the problem is in my .PNG Editor, i just make the image manually and it works!

im using Graphics Gale Free edition to edit and it will work.

i think the problem is in the PIL itself. Or The pyglet doesnt load PIL config PNG

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download