pub fn draw(&mut self, window: &mut Window) {
        if let Some(ref mut target) = window.target {
            let affine = self.transform.get_affine();

            match self.drawable.get_shader_items() {
                ThingToDraw::Img(vertex_buffer, index_buffer, texture) => {
                    let uniforms = uniform! {
                        matrix: affine,
                        tex: texture,
                    };

                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        ..Default::default()
                    };

                    target
                        .draw(
                            vertex_buffer,
                            index_buffer,
                            &window.img_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
                ThingToDraw::Shape(vertex_buffer, indices, polygon_mode) => {
                    let uniforms = uniform! {
                        matrix: affine,
                    };

                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        smooth: Some(Smooth::Nicest),
                        polygon_mode,
                        ..Default::default()
                    };
                    target
                        .draw(
                            vertex_buffer,
                            indices,
                            &window.shape_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
                ThingToDraw::ShaderShape(vertex_buffer, indices, local_scale) => {
                    let uniforms = uniform! {
                        matrix: affine,
                        local_scale: *local_scale,
                    };

                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        smooth: Some(Smooth::Nicest),
                        ..Default::default()
                    };
                    target
                        .draw(
                            vertex_buffer,
                            indices,
                            &window.shader_shape_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
            }
        }
    }
/// You must call a `Window`'s `.drawstart()` before calling this method.  `draw()` will draw your
/// image to the current off-screen framebuffer.  After the first time a given image value is
/// drawn it stays on the GPU and during subsequent calls it only sends updated
/// position/rotation, which is super efficient, so don't destroy and recreate images every
/// frame! Draw calls draw to the framebuffer in the order that they occur, so the last image
/// is on top.
You must call a `Window`'s `.drawstart()` before calling this method.  `draw()` will draw your
image to the current off-screen framebuffer.  After the first time a given image value is
drawn it stays on the GPU and during subsequent calls it only sends updated
position/rotation, which is super efficient, so don't destroy and recreate images every
frame. Draw calls draw to the framebuffer in the order that they occur, so the last image
is on top.
You must call a ` Window ` ' s ` . drawstart () ` before calling this method . ` draw () ` will draw your image to the current off - screen framebuffer . After the first time a given image value is drawn it stays on the GPU and during subsequent calls it only sends updated position / rotation which is super efficient so don ' t destroy and recreate images every frame . Draw calls draw to the framebuffer in the order that they occur so the last image is on top .
pub fn draw(&mut self, window: &mut Window) {
        if let Some(ref mut target) = window.target {
            let affine = self.transform.get_affine();
            match self.drawable.get_shader_items() {
                ThingToDraw::Img(vertex_buffer, index_buffer, texture) => {
                    let uniforms = uniform! {
                        matrix: affine,
                        tex: texture,
                    };
                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        ..Default::default()
                    };
                    target
                        .draw(
                            vertex_buffer,
                            index_buffer,
                            &window.img_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
                ThingToDraw::Shape(vertex_buffer, indices, polygon_mode) => {
                    let uniforms = uniform! {
                        matrix: affine,
                    };
                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        smooth: Some(Smooth::Nicest),
                        polygon_mode,
                        ..Default::default()
                    };
                    target
                        .draw(
                            vertex_buffer,
                            indices,
                            &window.shape_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
                ThingToDraw::ShaderShape(vertex_buffer, indices, local_scale) => {
                    let uniforms = uniform! {
                        matrix: affine,
                        local_scale: *local_scale,
                    };
                    let draw_parameters = DrawParameters {
                        blend: Blend::alpha_blending(),
                        smooth: Some(Smooth::Nicest),
                        ..Default::default()
                    };
                    target
                        .draw(
                            vertex_buffer,
                            indices,
                            &window.shader_shape_program,
                            &uniforms,
                            &draw_parameters,
                        )
                        .unwrap();
                }
            }
        }
    }
pub fn draw ( & mut self , window : & mut Window ) { if let Some ( ref mut target ) = window . target { let affine = self . transform . get_affine ( ) ; match self . drawable . get_shader_items ( ) { ThingToDraw :: Img ( vertex_buffer , index_buffer , texture ) => { let uniforms = uniform ! { matrix affine tex texture } ; let draw_parameters = DrawParameters { blend : Blend :: alpha_blending ( ) , .. Default :: default ( ) } ; target . draw ( vertex_buffer , index_buffer , & window . img_program , & uniforms , & draw_parameters , ) . unwrap ( ) ; } ThingToDraw :: Shape ( vertex_buffer , indices , polygon_mode ) => { let uniforms = uniform ! { matrix affine } ; let draw_parameters = DrawParameters { blend : Blend :: alpha_blending ( ) , smooth : Some ( Smooth :: Nicest ) , polygon_mode , .. Default :: default ( ) } ; target . draw ( vertex_buffer , indices , & window . shape_program , & uniforms , & draw_parameters , ) . unwrap ( ) ; } ThingToDraw :: ShaderShape ( vertex_buffer , indices , local_scale ) => { let uniforms = uniform ! { matrix affine local_scale local_scale } ; let draw_parameters = DrawParameters { blend : Blend :: alpha_blending ( ) , smooth : Some ( Smooth :: Nicest ) , .. Default :: default ( ) } ; target . draw ( vertex_buffer , indices , & window . shader_shape_program , & uniforms , & draw_parameters , ) . unwrap ( ) ; } } } }
You must call a `Window`'s `.drawstart()` before calling this method.
You must call a ` Window ` ' s ` . drawstart () ` before calling this method .
&mut self
window
&mut Window
&mut self
window
&mut Window