Exemplo n.º 1
0
    def render(self, model, color, num_turtles):
        self.program.bind()

        # no VAOs so have to set manually
        self.vertex_buffer.partition(
            [(self.vertex_attr, 4), (self.edge_attr, 3)]
        )
        self.indices_buffer.set(self.index_attr, 1)

        model_uniform = self.program.uniforms['turtle_model_array[0]']
        color_uniform = self.program.uniforms['turtle_color_array[0]']

        model_iter = model.slice(self.batch)
        color_iter = color.slice(self.batch)
        slices = zip(model_iter, color_iter)

        with measure("loop"):
            for (msize, model_slice), (csize, color_slice) in slices:
                assert msize == csize
                # load batch of turtle data
                with measure('load'):
                    model_uniform.set(model_slice, size=msize)
                    color_uniform.set(color_slice, size=msize)

                with measure('draw'):
                    glDrawArrays(
                        GL_TRIANGLES,
                        0,
                        len(self.geometry.edges) // 7 * msize,
                    )

        self.vertex_buffer.unbind()
        self.program.unbind()
Exemplo n.º 2
0
    def render(self, model, color, num_turtles):
        self.program.bind()

        # no VAOs so have to set manually
        self.vertex_buffer.partition([(self.vertex_attr, 4),
                                      (self.edge_attr, 3)])
        self.indices_buffer.set(self.index_attr, 1)

        model_uniform = self.program.uniforms['turtle_model_array[0]']
        color_uniform = self.program.uniforms['turtle_color_array[0]']

        model_iter = model.slice(self.batch)
        color_iter = color.slice(self.batch)
        slices = zip(model_iter, color_iter)

        with measure("loop"):
            for (msize, model_slice), (csize, color_slice) in slices:
                assert msize == csize
                # load batch of turtle data
                with measure('load'):
                    model_uniform.set(model_slice, size=msize)
                    color_uniform.set(color_slice, size=msize)

                with measure('draw'):
                    glDrawArrays(
                        GL_TRIANGLES,
                        0,
                        len(self.geometry.edges) // 7 * msize,
                    )

        self.vertex_buffer.unbind()
        self.program.unbind()
Exemplo n.º 3
0
def flip():
    with measure('flip'):
        _flip()
Exemplo n.º 4
0
def update(dt):
    with measure("update"):
        _update(dt, renderer.manager.buffers.values())
Exemplo n.º 5
0
def on_draw():
    with measure('render'):
        renderer.render(flip=False)
Exemplo n.º 6
0
def flip():
    with measure('flip'):
        _flip()
Exemplo n.º 7
0
def update(dt):
    with measure("update"):
        _update(dt, renderer.manager.buffers.values())
Exemplo n.º 8
0
def on_draw():
    with measure('render'):
        renderer.render(flip=False)