我一直在试图获得批次pyglet工作,但我完全被错误信息混淆“值过多解压”从未来pyglet/graphics/__init__.py
文件。我的猜测是,当将几何图形添加到批处理时,我在按照语法做出错误。“值过多解压错误”当试图创建pyglet一批
我我的代码削减到会产生错误的关键部分:
from pyglet.gl import *
from pyglet.graphics import *
import pyglet
batch = pyglet.graphics.Batch()
img = pyglet.image.load('pic.png')
texture = img.get_texture()
class TextureEnableGroup(pyglet.graphics.Group):
def set_state(self):
glEnable(GL_TEXTURE_2D)
def unset_state(self):
glDisable(GL_TEXTURE_2D)
texture_enable_group = TextureEnableGroup()
class TextureBindGroup(pyglet.graphics.Group):
def __init__(self, texture):
super(TextureBindGroup, self).__init__(parent=texture_enable_group)
self.texture = texture
def set_state(self):
glBindTexture(GL_TEXTURE_2D, self.texture.id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
def __eq__(self, other):
return (self.__class__ is other.__class__ and self.texture == other.__class__)
batch.add(12, GL_TRIANGLES, TextureBindGroup(texture), (('t2f', (0, 0)), ('v3f', (64, 64, 0)), ('t2f', (1, 1)), ('v3f', (-64, -64, 205)), ('t2f', (0, 1)), ('v3f', (-64, 64, 205)), ('t2f', (1, 1)), ('v3f', (64, -64, 205)), ('t2f', (1, 0)), ('v3f', (64, 64, 0)), ('t2f', (0, 1)), ('v3f', (-64, -64, 205))))
我想通了这一点使用谷歌,但rpoblem是某处pyglet Python文件内发生的错误。所以我想我没有以这种或那种方式正确使用batch.add()函数。问题在于;我应该如何使用它? – Bartvbl 2010-12-20 22:49:31
你需要阅读pyglet文档。你确定你在喂食什么?语法*是*不可读的。如何使用一些变量呢? – 2010-12-20 22:53:40