Beispiel #1
0
 def __init__(self, angleOfView=60, aspectRatio=1, near=0.1, far=1000):
     super().__init__()
     self.projectionMatrix = Matrix.perspective(angleOfView=angleOfView,
                                                aspectRatio=aspectRatio,
                                                near=near,
                                                far=far)
     self.viewMatrix = Matrix.identity()
Beispiel #2
0
 def draw(self, *args, **kwargs):
     Shader.upload_model(Matrix.identity())
     glActiveTexture(GL_TEXTURE1)
     self.normal[0].texture_bind()
     glActiveTexture(GL_TEXTURE0)
     self.texture[0].texture_bind()
     self.vbo.draw(*args, **kwargs)
Beispiel #3
0
    def render(self):
        glClearColor(1,0,1,1)
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

        camera = self.camera.copy()
        if self.projectile:
            camera.x = min(max(self.projectile.pos.x - 19, 0), self.camera_max)
            self.follow_cam = camera
        elif self.follow_cam:
            camera = self.follow_cam

        self.render_hud(camera)
        self.render_world(camera)

        mat = Matrix.scale(self.size.x, self.size.y)
        Shader.upload_projection_view(self.ortho, Matrix.identity())
        Shader.upload_model(mat)

        self.fbo.bind_texture()
        self.post.bind()
        self.quad.draw()

        y = self.size.x * (160./800)

        # hud background
        pm = Matrix.transform(
            0, y, 0,
            self.size.x, -y, 1
        )
        self.shader_hud.bind()
        self.hudbg.texture_bind()
        Shader.upload_model(pm)
        self.quad.draw()

        # ui
        pm = Matrix.transform(
            0, self.hud_ui.height, 0,
            self.hud_ui.width, -self.hud_ui.height, 1
        )
        self.hud_ui.draw()
        self.shader_hud.bind()
        Shader.upload_model(pm)
        self.quad.draw()

        # messagebox
        mat = Matrix.translate(self.size.x / 2 - self.hud_msgbox.width / 2, self.size.y - self.hud_msgbox.height)
        Shader.upload_model(mat)
        self.hud_msgbox.draw()

        # scrollbar
        mat = Matrix.translate(0, y-22)
        Shader.upload_model(mat)
        self.scrollbar.draw()

        pygame.display.flip()
Beispiel #4
0
 def __init__(self):
     self.transform = Matrix.identity()
     self.parent = None
     self.children = []