Beispiel #1
0
    def present(self):
        """Present updated buffers to screen."""

        def sort_key(op):
            return (op.key, op.shader.prog)

        polygon_mode = PolygonMode.fill

        current_shader = None
        for op in sorted(self.render_queue, key=sort_key, reverse=True):
            # perform actual rendering
            with ExitStack() as stack:
                for tex_unit, tex in enumerate(op.textures):
                    stack.enter_context(tex.use(tex_unit))

                if op.shader.prog != current_shader:
                    op.shader.use()
                    current_shader = op.shader.prog

                for k, v in op.shader_params.items():
                    # FIXME: rework this
                    if isinstance(v, Texture):
                        v = v.tex_unit
                    op.shader[k] = v

                # change the polygon mode, if requested by render op
                if polygon_mode != op.polygon_mode:
                    glPolygonMode(GL_FRONT_AND_BACK, op.polygon_mode)
                    polygon_mode = op.polygon_mode

                op.mesh.render()

        self.render_queue.clear()

        surrender.render()
Beispiel #2
0
    def render(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        self.shader['projection'] = self.projection_mat
        self.shader['modelview'] = self.modelview_mat
        self.shader['transform'] = self.transform_mat

        if self.play and self.current_anim:
            self.shader['animate'] = 1
            self.shader['joints[0]'] = self.current_anim.skin_transforms
        else:
            self.shader['animate'] = 0

        self.mesh.render()
        surrender.render()