예제 #1
0
파일: main.py 프로젝트: fathat/game-src
    def drawScreen( self ):
        """Draw the screen"""
        GraphicsCard.resetPolygonCount()
        GraphicsCard.enable('texture_2d', 'blend', 'cull_face')
        GraphicsCard.setBlendFunction('src_alpha', 'one_minus_src_alpha' )
        GraphicsCard.setFrontFace('ccw')

        GraphicsCard.loadIdentity()
        GraphicsCard.multMatrix( self.world.camera.getViewMatrix().toList() )
        glLightfv( GL_LIGHT0, GL_POSITION, [0, 1, 0, 0] )
        GraphicsCard.clearDepth(1.0)
        GraphicsCard.clear()

        #Draw the world
        self.world.draw()

        TextureManager.DisableStage( 1 )
        TextureManager.DisableStage( 2 )
        if Settings.UseShaders: Shader.DisableShaders()
        #self.font.draw( 0, 0, "FPS: " + str( self.fps ) )
        DebugDisplay.update("FPS", self.fps, delay=0.3333 )
        DebugDisplay.update("yaw", radianToDegree( self.world.camera.yaw) )
        DebugDisplay.update("pitch", radianToDegree( self.world.camera.pitch ))
        DebugDisplay.update("polygons_drawn", GraphicsCard.polygonsDrawn() )
        if self.world.playerEnt:
            DebugDisplay.update("onGround", self.world.playerEnt.onGround )
            DebugDisplay.update("groundNormal", self.world.playerEnt.groundNormal )


        GraphicsCard.loadIdentity()
        if self.consoleVisible:
            self.console.draw()
        gl2D.start2D()
        if Settings.DrawDebugInfo:
            GraphicsCard.setColorRGBA(1, 1, 1, 1)
            self.font.draw(0, 0, str(DebugDisplay.globalState))
            self.world.scene.drawDebugInfo(self.font)
        else:
            GraphicsCard.setColorRGBA(1, 1, 1, 1)
            pygame.display.set_caption("FPS: " + str(DebugDisplay.get("FPS")))
            #self.bigfont.draw(0, 0, "Ninjas  Killed: %s" % (self.world.ninjasKilled) )
            #self.bigfont.draw(0, 30, "Pirates Killed: %s" % (self.world.piratesKilled) )
            #self.bigfont.draw(0, 60, "Treasures Stolen: %s" % (self.world.treasuresTaken) )
        #DebugDisplay.globalState.draw( self.font )
        gl2D.end2D()
        #put stuff on the screen
        pygame.display.flip()

        err = graphext.GetGLError()
        while err != GL_NO_ERROR:
            print err
            print graphext.GLErrorString( err)
예제 #2
0
    def drawScreen(self):
        """Draw the screen"""
        GraphicsCard.resetPolygonCount()
        GraphicsCard.enable('texture_2d', 'blend', 'cull_face')
        GraphicsCard.setBlendFunction('src_alpha', 'one_minus_src_alpha')
        GraphicsCard.setFrontFace('ccw')

        GraphicsCard.loadIdentity()
        GraphicsCard.multMatrix(self.world.camera.getViewMatrix().toList())
        glLightfv(GL_LIGHT0, GL_POSITION, [0, 1, 0, 0])
        GraphicsCard.clearDepth(1.0)
        GraphicsCard.clear()

        #Draw the world
        self.world.draw()

        TextureManager.DisableStage(1)
        TextureManager.DisableStage(2)
        if Settings.UseShaders: Shader.DisableShaders()
        #self.font.draw( 0, 0, "FPS: " + str( self.fps ) )
        DebugDisplay.update("FPS", self.fps, delay=0.3333)
        DebugDisplay.update("yaw", radianToDegree(self.world.camera.yaw))
        DebugDisplay.update("pitch", radianToDegree(self.world.camera.pitch))
        DebugDisplay.update("polygons_drawn", GraphicsCard.polygonsDrawn())
        if self.world.playerEnt:
            DebugDisplay.update("onGround", self.world.playerEnt.onGround)
            DebugDisplay.update("groundNormal",
                                self.world.playerEnt.groundNormal)

        GraphicsCard.loadIdentity()
        if self.consoleVisible:
            self.console.draw()
        gl2D.start2D()
        if Settings.DrawDebugInfo:
            GraphicsCard.setColorRGBA(1, 1, 1, 1)
            self.font.draw(0, 0, str(DebugDisplay.globalState))
            self.world.scene.drawDebugInfo(self.font)
        else:
            GraphicsCard.setColorRGBA(1, 1, 1, 1)
            pygame.display.set_caption("FPS: " + str(DebugDisplay.get("FPS")))
            #self.bigfont.draw(0, 0, "Ninjas  Killed: %s" % (self.world.ninjasKilled) )
            #self.bigfont.draw(0, 30, "Pirates Killed: %s" % (self.world.piratesKilled) )
            #self.bigfont.draw(0, 60, "Treasures Stolen: %s" % (self.world.treasuresTaken) )
        #DebugDisplay.globalState.draw( self.font )
        gl2D.end2D()
        #put stuff on the screen
        pygame.display.flip()

        err = graphext.GetGLError()
        while err != GL_NO_ERROR:
            print err
            print graphext.GLErrorString(err)