我一直在試圖獲得批次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