fn render_lots(
        &self,
        it: &mut std::iter::Peekable<impl Iterator<Item = Arc<Renderable>>>,
        vbo: &mut glium::buffer::WriteMapping<[Vertex]>,
        ibo: &mut glium::buffer::WriteMapping<[u32]>,
        render_target: &mut impl glium::Surface,
        program: &glium::Program,
        uniforms: &impl glium::uniforms::Uniforms,
        params: &glium::DrawParameters,
    ) -> usize {
        let mut current_vertex = 0;
        let mut current_index = 0;
        loop {
            match it.peek() {
                Some(r) => {
                    match **r {
                        Renderable::None => {
                            it.next();
                        }
                        Renderable::Triangle(v0, v1, v2) => {
                            if current_index + 3 >= MAX_INDS || current_vertex + 3 >= MAX_VERTS {
                                break; // Do not consume the triangle, leave it to the next call to render_lots.
                            }
                            vbo.set(current_vertex + 0, conv(&v0));
                            vbo.set(current_vertex + 1, conv(&v1));
                            vbo.set(current_vertex + 2, conv(&v2));
                            ibo.set(current_index + 0, (current_vertex + 0) as u32);
                            ibo.set(current_index + 1, (current_vertex + 1) as u32);
                            ibo.set(current_index + 2, (current_vertex + 2) as u32);
                            current_vertex += 3;
                            current_index += 3;
                            it.next();
                        }
                        Renderable::Mesh(i) => {
                            let mesh = &self.meshes.borrow()[&i];
                            render_target
                                .draw(&mesh.vbo, &mesh.ibo, program, uniforms, params)
                                .unwrap();
                            it.next();
                        }
                    }
                }
                None => break,
            }
        }
        current_index
    }
/// Render as many things from the given iterator as we can in the current batch, returning the (exclusive) max index we wrote to.
Render as many things from the given iterator as we can in the current batch, returning the (exclusive) max index we wrote to.
Render as many things from the given iterator as we can in the current batch returning the ( exclusive ) max index we wrote to .
fn render_lots(
        &self,
        it: &mut std::iter::Peekable<impl Iterator<Item = Arc<Renderable>>>,
        vbo: &mut glium::buffer::WriteMapping<[Vertex]>,
        ibo: &mut glium::buffer::WriteMapping<[u32]>,
        render_target: &mut impl glium::Surface,
        program: &glium::Program,
        uniforms: &impl glium::uniforms::Uniforms,
        params: &glium::DrawParameters,
    ) -> usize {
        let mut current_vertex = 0;
        let mut current_index = 0;
        loop {
            match it.peek() {
                Some(r) => {
                    match **r {
                        Renderable::None => {
                            it.next();
                        }
                        Renderable::Triangle(v0, v1, v2) => {
                            if current_index + 3 >= MAX_INDS || current_vertex + 3 >= MAX_VERTS {
                                break; // Do not consume the triangle, leave it to the next call to render_lots.
                            }
                            vbo.set(current_vertex + 0, conv(&v0));
                            vbo.set(current_vertex + 1, conv(&v1));
                            vbo.set(current_vertex + 2, conv(&v2));
                            ibo.set(current_index + 0, (current_vertex + 0) as u32);
                            ibo.set(current_index + 1, (current_vertex + 1) as u32);
                            ibo.set(current_index + 2, (current_vertex + 2) as u32);
                            current_vertex += 3;
                            current_index += 3;
                            it.next();
                        }
                        Renderable::Mesh(i) => {
                            let mesh = &self.meshes.borrow()[&i];
                            render_target
                                .draw(&mesh.vbo, &mesh.ibo, program, uniforms, params)
                                .unwrap();
                            it.next();
                        }
                    }
                }
                None => break,
            }
        }
        current_index
    }
fn render_lots ( & self , it : & mut std :: iter :: Peekable < impl Iterator < Item = Arc < Renderable > > > , vbo : & mut glium :: buffer :: WriteMapping < [ Vertex ] > , ibo : & mut glium :: buffer :: WriteMapping < [ u32 ] > , render_target : & mut impl glium :: Surface , program : & glium :: Program , uniforms : & impl glium :: uniforms :: Uniforms , params : & glium :: DrawParameters , ) -> usize { let mut current_vertex = 0 ; let mut current_index = 0 ; loop { match it . peek ( ) { Some ( r ) => { match * * r { Renderable :: None => { it . next ( ) ; } Renderable :: Triangle ( v0 , v1 , v2 ) => { if current_index + 3 >= MAX_INDS || current_vertex + 3 >= MAX_VERTS { break ; // Do not consume the triangle, leave it to the next call to render_lots. } vbo . set ( current_vertex + 0 , conv ( & v0 ) ) ; vbo . set ( current_vertex + 1 , conv ( & v1 ) ) ; vbo . set ( current_vertex + 2 , conv ( & v2 ) ) ; ibo . set ( current_index + 0 , ( current_vertex + 0 ) as u32 ) ; ibo . set ( current_index + 1 , ( current_vertex + 1 ) as u32 ) ; ibo . set ( current_index + 2 , ( current_vertex + 2 ) as u32 ) ; current_vertex += 3 ; current_index += 3 ; it . next ( ) ; } Renderable :: Mesh ( i ) => { let mesh = & self . meshes . borrow ( ) [ & i ] ; render_target . draw ( & mesh . vbo , & mesh . ibo , program , uniforms , params ) . unwrap ( ) ; it . next ( ) ; } } } None => break , } } current_index }
Render as many things from the given iterator as we can in the current batch, returning the (exclusive) max index we wrote to.
Render as many things from the given iterator as we can in the current batch returning the ( exclusive ) max index we wrote to .
&self
it
&mut std::iter::Peekable<impl Iterator<Item = Arc<Renderable>>>
vbo
&mut glium::buffer::WriteMapping<[Vertex]>
ibo
&mut glium::buffer::WriteMapping<[u32]>
render_target
&mut impl glium::Surface
program
&glium::Program
uniforms
&impl glium::uniforms::Uniforms
params
&glium::DrawParameters
&self
it
&mut std::iter::Peekable<impl Iterator<Item = Arc<Renderable>>>
vbo
&mut glium::buffer::WriteMapping<[Vertex]>
ibo
&mut glium::buffer::WriteMapping<[u32]>
render_target
&mut impl glium::Surface
program
&glium::Program
uniforms
&impl glium::uniforms::Uniforms
params
&glium::DrawParameters