class CharInfo( object ): """A single character in a TextureFont""" __slots__ = ('id', 'x', 'y', 'width', 'height', 'xoffset', 'yoffset', 'xadvance', 'page', 'displayList', '__weakref__') def __init__( self, tokens ): self.displayList = None for t in tokens: attr, val = parse_equals_statement ( t ) setattr( self, attr, val ) def buildDisplayList(self, texturePages): def renderChar(): texpage = texturePages[self.page] glBegin(GL_QUADS) drawQuad(texpage.width, texpage.height, #texture width, texture height self.xoffset, self.yoffset, #destination xy self.x, self.y, #source xy self.width, self.height ) #source width/height glEnd() self.displayList = DisplayList( renderChar ) def draw(self): self.displayList.execute()
class CharInfo(object): """A single character in a TextureFont""" __slots__ = ('id', 'x', 'y', 'width', 'height', 'xoffset', 'yoffset', 'xadvance', 'page', 'displayList', '__weakref__') def __init__(self, tokens): self.displayList = None for t in tokens: attr, val = parse_equals_statement(t) setattr(self, attr, val) def buildDisplayList(self, texturePages): def renderChar(): texpage = texturePages[self.page] glBegin(GL_QUADS) drawQuad( texpage.width, texpage.height, #texture width, texture height self.xoffset, self.yoffset, #destination xy self.x, self.y, #source xy self.width, self.height) #source width/height glEnd() self.displayList = DisplayList(renderChar) def draw(self): self.displayList.execute()