Пример #1
0
 def enter(self):
     GL.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TEXTURE_BIT)
     scale = self.scale
     GL.glMatrixMode(GL.GL_TEXTURE)
     GL.glPushMatrix()
     GL.glLoadIdentity()
     if scale is not None:
         GL.glScale(*scale)
     glutils.glActiveTexture(GL.GL_TEXTURE0)  # disable texture1?
     GL.glEnable(GL.GL_TEXTURE_2D)
     if self.texture is not None:
         self.texture.bind()
Пример #2
0
    def exit(self):
        if self.sceneNode.textureAtlas is None:
            return

        GL.glDisable(GL.GL_CULL_FACE)
        glutils.glActiveTexture(GL.GL_TEXTURE1)
        GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
        GL.glDisable(GL.GL_TEXTURE_2D)
        GL.glMatrixMode(GL.GL_TEXTURE)
        GL.glPopMatrix()

        glutils.glActiveTexture(GL.GL_TEXTURE0)
        GL.glDisable(GL.GL_TEXTURE_2D)
        GL.glMatrixMode(GL.GL_TEXTURE)
        GL.glPopMatrix()
Пример #3
0
    def enter(self):
        if self.sceneNode.textureAtlas is None:
            return

        GL.glColor(1., 1., 1., 1.)
        textureAtlas = self.sceneNode.textureAtlas
        glutils.glActiveTexture(GL.GL_TEXTURE0)
        GL.glEnable(GL.GL_TEXTURE_2D)
        textureAtlas.bindTerrain()

        GL.glMatrixMode(GL.GL_TEXTURE)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glScale(1. / textureAtlas.width, 1. / textureAtlas.height, 1.)

        glutils.glActiveTexture(GL.GL_TEXTURE1)
        GL.glEnable(GL.GL_TEXTURE_2D)
        textureAtlas.bindLight()

        GL.glMatrixMode(GL.GL_TEXTURE)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glScale(1. / 16, 1. / 16, 1.)

        glutils.glActiveTexture(GL.GL_TEXTURE0)
        GL.glEnable(GL.GL_CULL_FACE)
Пример #4
0
    def drawSelf(self):
        self.didDraw = True
        bare = []
        withTex = []
        withLights = []
        for array in self.sceneNode.vertexArrays:
            if array.lights:
                withLights.append(array)
            elif array.textures:
                withTex.append(array)
            else:
                bare.append(array)

        with gl.glPushAttrib(GL.GL_ENABLE_BIT):
            if len(bare):
                glutils.glActiveTexture(GL.GL_TEXTURE0)
                GL.glDisable(GL.GL_TEXTURE_2D)
                glutils.glActiveTexture(GL.GL_TEXTURE1)
                GL.glDisable(GL.GL_TEXTURE_2D)
                glutils.glActiveTexture(GL.GL_TEXTURE0)
                self.drawArrays(bare, False, False)

            if len(withTex) or len(withLights):
                glutils.glActiveTexture(GL.GL_TEXTURE0)
                GL.glEnable(GL.GL_TEXTURE_2D)

            if len(withTex):
                self.drawArrays(withTex, True, False)

            if len(withLights):
                glutils.glActiveTexture(GL.GL_TEXTURE1)
                GL.glEnable(GL.GL_TEXTURE_2D)
                glutils.glActiveTexture(GL.GL_TEXTURE0)
                self.drawArrays(withLights, True, True)