Example #1
0
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()
Example #2
0
 def draw(self, rstate):
     """Animate the texture coordinates every frame"""
     self.motion.integrate(self.time.step())
     glActiveTextureARB(GL_TEXTURE1_ARB)
     glTexGenfv(GL_S, GL_OBJECT_PLANE, (self.scale, 0, 0, self.motion.value))
     glActiveTextureARB(GL_TEXTURE0_ARB)
     DisplayList.draw(self, rstate)
Example #3
0
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()
Example #4
0
 def __init__(self, indices, usage=GL_STATIC_DRAW_ARB, element_type='H'):
     DisplayList.checkForInvalidCall(
         "Should not construct IndexBuffers in a display list")
     self.id = GenerateID()
     self.usage = usage
     self.indices = indices
     self.elementType = element_type
     self.glTypeCode = array_type_to_gl_type[element_type]
     self._loaddata()
Example #5
0
 def __init__(self, datablocks, usage=GL_STATIC_DRAW_ARB):
     """Initializes the vertex buffer object with the given data blocks"""
     DisplayList.checkForInvalidCall(
         "Should not construct VertexBuffers in a display list")
     self.dataBlocks = datablocks[:]
     self.totalSize = 0
     self.usage = usage
     self.id = GenerateID()
     self._upload()
Example #6
0
def MakeTexture( filename ):
    global extensions
    DisplayList.checkForInvalidCall("Loading texture %s in a display list " % (filename))
    ext = os.path.splitext( filename )[1]
    if ext in extensions:
        extensions[ext] += 1
    else:
        extensions[ext] = 1
    if filename.endswith( '.dds' ):
        return DDSTexture( filename )
    else:
        return Texture( filename )
Example #7
0
def MakeTexture(filename):
    global extensions
    DisplayList.checkForInvalidCall("Loading texture %s in a display list " %
                                    (filename))
    ext = os.path.splitext(filename)[1]
    if ext in extensions:
        extensions[ext] += 1
    else:
        extensions[ext] = 1
    if filename.endswith('.dds'):
        return DDSTexture(filename)
    else:
        return Texture(filename)
Example #8
0
    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)
Example #9
0
 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 )
Example #10
0
    def _buildLowDetailDisplayList(self):
        #make sure all the textures are loaded BEFORE we create the display
        #list.
        self.material.precacheGraphics()

        def _commands():
            self.material.start()
            self.drawSinglePass()
            self.material.end()

        self.displayList = DisplayList(_commands)
Example #11
0
    def makeDisplayListforString(self, text):
        print """ Making display list for... "%s" """ % (text)
        size = []

        def build_dl():
            w, h = self.drawPrim(0, 0, text)
            size.extend([w, h])

        display_list = DisplayList(build_dl)
        self.optimizedStrings[text] = (display_list, w, h)
        return display_list, w, h
    def addTabs(self):
        self.lists = self.reader.readLists()

        for list in self.lists:
            self.tabsList.append(DisplayList(list))

        self.tabsList.append(CreateNewList(self.reloadList))

        for index, tab in enumerate(self.tabsList):
            if (index < len(self.tabsList) - 1):
                self.tabs.addTab(tab, f'{self.lists[index]["list_name"]}')
            else:
                self.tabs.addTab(tab, '+')
Example #13
0
    def _buildHighDetailDisplayList(self):
        if Settings.DrawGrass:
            self.buildGrassDL()

        #make sure all the textures are loaded BEFORE we create the display
        #list.
        self.material.precacheGraphics()
        self._buildPrimCL()

        print "Constructing main display list..."

        def _commands():
            #set some initial states
            glEnable(GL_TEXTURE_2D)
            glDisable(GL_LIGHTING)
            glDepthFunc(GL_LEQUAL)

            #Load in the material, and draw each layer
            mat = self.material
            mat.start()
            print "Material bound..."
            i = 0
            if Settings.UseVBO:
                print "Binding vertex buffer"
                self.vertexbuffer.bind()
                print "Binding index buffer"
                self.indexbuffer.bind()
            glFrontFace(GL_CCW)
            for l in mat.layers:
                l.use()
                #Graphics.setTextureAnisotropy( 8.0 )
                #print Graphics.getTextureAnisotropy()
                if Settings.UseVBO:
                    self.indexbuffer.drawWithoutBinding()
                else:
                    self.primDL()
                #self.drawVertexArrays()
                i += 1
            if Settings.UseVBO:
                print "Unbinding IB"
                self.indexbuffer.unbind()
                print "Unbinding VB"
                self.vertexbuffer.unbind()
            mat.end()

            glDepthFunc(GL_LESS)

        self.displayList = DisplayList(_commands)
        print "Done"
 def reloadList(self):
     self.lists = self.reader.readLists()
     list = self.lists[self.tabs.count() - 1]
     self.tabs.addTab(DisplayList(list), f'{list["list_name"]}')
Example #15
0
 def buildGrassDL(self):
     self.grassDisplayList = DisplayList(lambda: self.grassPatch.draw())
Example #16
0
 def _buildPrimCL(self):
     self.primDL = DisplayList(lambda: self.drawPrim())
     print "Built primitive display list"
Example #17
0
def _makeSphere():
    global _sphere
    global _circleQuad
    _circleQuad = gluNewQuadric()
    _sphere = DisplayList((lambda: gluSphere(_circleQuad, 1.0, 12, 12)))
Example #18
0
 def __init__(self, points, radius, linewidth):
     if not _sphere: _makeSphere()
     self.displayList = DisplayList(
         lambda: drawPath(points, radius, linewidth))
Example #19
0
 def draw(self, rstate):
     glTexGenfv(GL_S, GL_OBJECT_PLANE, (0, 0, 0, self.sky.unitDayTime))
     DisplayList.draw(self, rstate)
Example #20
0
 def buildDisplayList(self):
     self.precacheSubmeshes()
     self.display_list = DisplayList(lambda: self.drawSimple())