Exemplo n.º 1
0
    def orthogonalPass(self, debugShadows=False):
        """
        draw stuff in orthogonal projection.
        mainly the scene can be post processed here
        and some gui elements could be drawn.
        """

        ### DRAW THE SCENE ###

        # TODO: post shader magic !
        glUseProgram(0)

        # enable the scene texture
        # Note that texture unit 0 should be active now.
        glEnable(GL_TEXTURE_2D)
        glBindTexture(GL_TEXTURE_2D, self.sceneTexture.glID)
        # make sure texture matrix is set to identity
        glMatrixMode(GL_TEXTURE)
        glLoadIdentity()
        glMatrixMode(GL_MODELVIEW)

        glBegin(GL_QUADS)
        glTexCoord2f(0.0, 0.0)
        glVertex3f(0.0, 0.0, -1.0)
        glTexCoord2f(1.0, 0.0)
        glVertex3f(self.winSize[0], 0.0, -1.0)
        glTexCoord2f(1.0, 1.0)
        glVertex3f(self.winSize[0], self.winSize[1], -1.0)
        glTexCoord2f(0.0, 1.0)
        glVertex3f(0.0, self.winSize[1], -1.0)
        glEnd()

        ### DEBUG DRAWINGS ###

        # debug shadow maps
        if debugShadows:
            # draw the shadow maps
            self.visualizeDepthShader.enable()
            layerLoc = glGetUniformLocation(self.visualizeDepthShader.program, "layer")
            drawShadowMaps(self.lights, layerLoc)

            # reset viewport and reset to ffp
            glViewport(0, 0, self.winSize[0], self.winSize[1])
            glUseProgram(0)

        glBindTexture(GL_TEXTURE_2D, 0)
        glDisable(GL_TEXTURE_2D)

        GLApp.orthogonalPass(self)
Exemplo n.º 2
0
 def setWindowSize(self, size):
     """
     also set frustum projection.
     """
     ret = GLApp.setWindowSize(self, size)
     # set the frustum projection
     self.sceneFrustum.setProjection(self.fov, self.aspect, self.nearClip, self.farClip)
     return ret
Exemplo n.º 3
0
    def __init__(self):
        self.models = []
        self.lights = []
        # render to texture scenes
        self.sceneFBOS = []
        # all units <self.textureCounter are reserved
        self.textureCounter = 0
        self.textureMatrixCounter = 0

        # matrix used for projective textures will be stored at this unit
        # only used when self.useProjectiveTextures=True
        self.useProjectiveTextures = False
        self.projectiveTextureIndex = -1
        self.projectiveTextureMatrixIndex = -1
        self.projectivTextureMatrix = ProjectiveTextureMatrix(self)
        # set to true if you need the frustum points/centroid calculated
        self.needFrustumPoints = False

        # and the associated frustum
        self.sceneFrustum = Frustum(0.0, 1.0)

        GLApp.__init__(self)

        # camera for user movement
        self.sceneCamera = UserCamera(self)

        # create screen textures
        self.sceneTexture = Texture2D(width=self.winSize[0], height=self.winSize[1])
        self.sceneTexture.create()
        self.sceneDepthTexture = DepthTexture2D(width=self.winSize[0], height=self.winSize[1])
        self.sceneDepthTexture.create()

        # a shader that only handles the depth
        self.depthShader = DepthShader()
        self.visualizeDepthShader = VisualizeDepthShader()

        ### TESTING ###
        self.lightAngle = 0.0