Ejemplo n.º 1
0
    def render(self, matrix, layer):
        self.__update_vert_vbo()
        self.__update_index_vbo()

        overall_color = self.__view.color_for_layer(layer)
        sel_color  = self.__view.sel_colormod(True, overall_color)

        def _c_for_rs(rs):
            if rs & RENDER_SELECTED:
                return tuple(sel_color) + (1,)
            else:
                return tuple(overall_color) + (1,)


        with self.__shader, self.__vao:
            GL.glUniformMatrix3fv(self.__shader.uniforms.mat, 1, True, matrix.ctypes.data_as(GLI.c_float_p))

            for rs, ranges in self.__deferred_tri_render_ranges.items():
                tri_draw_list = get_consolidated_draws(ranges)
                GL.glUniform4f(self.__shader.uniforms.color, *_c_for_rs(rs))

                for first, last in tri_draw_list:
                        GL.glDrawElements(GL.GL_TRIANGLES, last - first, GL.GL_UNSIGNED_INT, ctypes.c_void_p(first * 4))

            GL.glEnable(GL.GL_PRIMITIVE_RESTART)
            GL.glPrimitiveRestartIndex(self.__RESTART_INDEX)
            for rs, ranges in self.__deferred_line_render_ranges.items():
                GL.glUniform4f(self.__shader.uniforms.color, *_c_for_rs(rs))
                line_draw_list = get_consolidated_draws(ranges)
                for first, last in line_draw_list:
                        GL.glDrawElements(GL.GL_LINE_STRIP, last - first, GL.GL_UNSIGNED_INT, ctypes.c_void_p((first + self.__outline_index_offset) * 4))
            GL.glDisable(GL.GL_PRIMITIVE_RESTART)
Ejemplo n.º 2
0
    def render(self, matrix, layer):
        self.__update_vert_vbo()
        self.__update_index_vbo()

        overall_color = self.__view.color_for_layer(layer)
        sel_color = self.__view.sel_colormod(True, overall_color)

        def _c_for_rs(rs):
            if rs & RENDER_SELECTED:
                return tuple(sel_color) + (1, )
            else:
                return tuple(overall_color) + (1, )

        with self.__shader.program, self.__vao:
            GL.glUniformMatrix3fv(self.__shader.uniforms.mat, 1, True,
                                  matrix.astype(numpy.float32))

            for rs, ranges in self.__deferred_tri_render_ranges.items():
                tri_draw_list = get_consolidated_draws(ranges)
                GL.glUniform4f(self.__shader.uniforms.color, *_c_for_rs(rs))

                for first, last in tri_draw_list:
                    GL.glDrawElements(GL.GL_TRIANGLES, last - first,
                                      GL.GL_UNSIGNED_INT,
                                      ctypes.c_void_p(first * 4))

            GL.glEnable(GL.GL_PRIMITIVE_RESTART)
            GL.glPrimitiveRestartIndex(self.__RESTART_INDEX)
            for rs, ranges in self.__deferred_line_render_ranges.items():
                GL.glUniform4f(self.__shader.uniforms.color, *_c_for_rs(rs))
                line_draw_list = get_consolidated_draws(ranges)
                for first, last in line_draw_list:
                    GL.glDrawElements(
                        GL.GL_LINE_STRIP, last - first, GL.GL_UNSIGNED_INT,
                        ctypes.c_void_p(
                            (first + self.__outline_index_offset) * 4))

            GL.glDisable(GL.GL_PRIMITIVE_RESTART)
Ejemplo n.º 3
0
    def __render_class(self, offset, tags, reservations=[]):
        color_batches = defaultdict(list)
        for idx, color in tags:
            color_batches[color].append((idx, idx + 1))

        for reservation, color in reservations:
            color_batches[color].append((reservation.first, reservation.last + 1))

        for color, indicies in color_batches.items():
            color = tuple(color) + (1,)
            batches = get_consolidated_draws(indicies)
            GL.glUniform4f(self.__shader.uniforms.color, *color)
            for first, last in batches:
                GL.glDrawArrays(GL.GL_LINES, offset + first * 2, (last - first) * 2)
Ejemplo n.º 4
0
    def __render_class(self, offset, tags, reservations=[]):
        color_batches = defaultdict(list)
        for idx, color in tags:
            color_batches[color].append((idx, idx + 1))

        for reservation, color in reservations:
            color_batches[color].append(
                (reservation.first, reservation.last + 1))

        for color, indicies in color_batches.items():
            color = tuple(color) + (1, )
            batches = get_consolidated_draws(indicies)
            GL.glUniform4f(self.__shader.uniforms.color, *color)
            for first, last in batches:
                GL.glDrawArrays(GL.GL_LINES, offset + first * 2,
                                (last - first) * 2)