pub fn draw(
        &mut self,
        queue: Arc<Queue>,
        image_map: &image::Map<Image>,
        viewport: [f32; 4],
    ) -> Result<Vec<DrawCommand>, DrawError> {
        let current_viewport = Viewport {
            origin: [viewport[0], viewport[1]],
            dimensions: [viewport[2] - viewport[0], viewport[3] - viewport[1]],
            depth_range: 0.0..1.0,
        };

        let mut current_scizzor = Scissor {
            origin: [viewport[0] as u32, viewport[1] as u32],
            dimensions: [
                (viewport[2] - viewport[0]) as u32,
                (viewport[3] - viewport[1]) as u32,
            ],
        };

        let conv_scizzor = |s: mesh::Scizzor| Scissor {
            origin: [s.top_left[0] as u32, s.top_left[1] as u32],
            dimensions: s.dimensions,
        };
        // ?????????????????? is there any reason to use self.tex_descs
        let mut desc_set_builder = self.tex_descs.next();
        desc_set_builder.add_sampled_image(
            ImageView::new(self.glyph_cache_tex.clone()).unwrap(),
            self.sampler.clone(),
        )?;
        let desc_cache = Arc::new(desc_set_builder.build()?);

        let commands = self.mesh.commands();

        let mut draw_commands = vec![];

        for command in commands {
            match command {
                // Update the `scizzor` before continuing to draw.
                mesh::Command::Scizzor(scizzor) => current_scizzor = conv_scizzor(scizzor),

                // Draw to the target with the given `draw` command.
                mesh::Command::Draw(draw) => match draw {
                    // Draw text and plain 2D geometry.
                    mesh::Draw::Plain(vert_range) => {
                        if !vert_range.is_empty() {
                            let verts = &self.mesh.vertices()[vert_range];
                            let verts = conv_vertex_buffer(verts);
                            let (vbuf, vbuf_fut) = ImmutableBuffer::<[Vertex]>::from_iter(
                                verts.iter().cloned(),
                                BufferUsage::vertex_buffer(),
                                queue.clone(),
                            )?;
                            vbuf_fut
                                .then_signal_fence_and_flush()
                                .expect("failed to flush future")
                                .wait(None)
                                .unwrap();
                            draw_commands.push(DrawCommand {
                                graphics_pipeline: self.pipeline.clone(),
                                scissor: current_scizzor,
                                viewport: current_viewport.clone(),
                                vertex_buffer: vbuf,
                                descriptor_set: desc_cache.clone(),
                            });
                        }
                    }

                    // Draw an image whose texture data lies within the `image_map` at the
                    // given `id`.
                    mesh::Draw::Image(image_id, vert_range) => {
                        if vert_range.is_empty() {
                            continue;
                        }
                        if let Some(image) = image_map.get(&image_id) {
                            // ??????????? is there any reason to use self.tex_descs
                            /*
                            let tex_desc = self
                                .tex_descs
                                .next()
                                .add_sampled_image(
                                    ImageView::new(image.image_access.clone()).unwrap(),
                                    self.sampler.clone(),
                                ).unwrap()
                                .build()?;*/
                            let mut desc_set_builder = self.tex_descs.next();
                            desc_set_builder.add_sampled_image(
                                ImageView::new(image.image_access.clone()).unwrap(),
                                self.sampler.clone(),
                            )?;
                            let desc_image = Arc::new(desc_set_builder.build()?);

                            //let desc_image = Arc::new(tex_desc);

                            let verts = &self.mesh.vertices()[vert_range];
                            let verts = conv_vertex_buffer(verts);
                            let (vbuf, vbuf_fut) = ImmutableBuffer::from_iter(
                                verts.iter().cloned(),
                                BufferUsage::vertex_buffer(),
                                queue.clone(),
                            )?;
                            vbuf_fut
                                .then_signal_fence_and_flush()
                                .unwrap()
                                .wait(None)
                                .unwrap();
                            draw_commands.push(DrawCommand {
                                graphics_pipeline: self.pipeline.clone(),
                                scissor: current_scizzor,
                                viewport: current_viewport.clone(),
                                vertex_buffer: vbuf,
                                descriptor_set: desc_image,
                            });
                        }
                    }
                },
            }
        }

        Ok(draw_commands)
    }
/// Draws using the inner list of `Command`s to a list of `DrawCommand`s compatible with the
/// vulkano command buffer builders.
///
/// Uses the given `queue` for submitting vertex buffers.
///
/// Note: If you require more granular control over rendering, you may want to use the `fill`
/// and `commands` methods separately. This method is simply a convenience wrapper around those
/// methods for the case that the user does not require accessing or modifying conrod's draw
/// parameters, uniforms or generated draw commands.
Draws using the inner list of `Command`s to a list of `DrawCommand`s compatible with the
vulkano command buffer builders.

Uses the given `queue` for submitting vertex buffers.

If you require more granular control over rendering, you may want to use the `fill`
and `commands` methods separately. This method is simply a convenience wrapper around those
methods for the case that the user does not require accessing or modifying conrod's draw
parameters, uniforms or generated draw commands.
Draws using the inner list of ` Command ` s to a list of ` DrawCommand ` s compatible with the vulkano command buffer builders . Uses the given ` queue ` for submitting vertex buffers . If you require more granular control over rendering you may want to use the ` fill ` and ` commands ` methods separately . This method is simply a convenience wrapper around those methods for the case that the user does not require accessing or modifying conrod ' s draw parameters uniforms or generated draw commands .
pub fn draw(
        &mut self,
        queue: Arc<Queue>,
        image_map: &image::Map<Image>,
        viewport: [f32; 4],
    ) -> Result<Vec<DrawCommand>, DrawError> {
        let current_viewport = Viewport {
            origin: [viewport[0], viewport[1]],
            dimensions: [viewport[2] - viewport[0], viewport[3] - viewport[1]],
            depth_range: 0.0..1.0,
        };
        let mut current_scizzor = Scissor {
            origin: [viewport[0] as u32, viewport[1] as u32],
            dimensions: [
                (viewport[2] - viewport[0]) as u32,
                (viewport[3] - viewport[1]) as u32,
            ],
        };
        let conv_scizzor = |s: mesh::Scizzor| Scissor {
            origin: [s.top_left[0] as u32, s.top_left[1] as u32],
            dimensions: s.dimensions,
        };
        // ?????????????????? is there any reason to use self.tex_descs
        let mut desc_set_builder = self.tex_descs.next();
        desc_set_builder.add_sampled_image(
            ImageView::new(self.glyph_cache_tex.clone()).unwrap(),
            self.sampler.clone(),
        )?;
        let desc_cache = Arc::new(desc_set_builder.build()?);
        let commands = self.mesh.commands();
        let mut draw_commands = vec![];
        for command in commands {
            match command {
                // Update the `scizzor` before continuing to draw.
                mesh::Command::Scizzor(scizzor) => current_scizzor = conv_scizzor(scizzor),
                // Draw to the target with the given `draw` command.
                mesh::Command::Draw(draw) => match draw {
                    // Draw text and plain 2D geometry.
                    mesh::Draw::Plain(vert_range) => {
                        if !vert_range.is_empty() {
                            let verts = &self.mesh.vertices()[vert_range];
                            let verts = conv_vertex_buffer(verts);
                            let (vbuf, vbuf_fut) = ImmutableBuffer::<[Vertex]>::from_iter(
                                verts.iter().cloned(),
                                BufferUsage::vertex_buffer(),
                                queue.clone(),
                            )?;
                            vbuf_fut
                                .then_signal_fence_and_flush()
                                .expect("failed to flush future")
                                .wait(None)
                                .unwrap();
                            draw_commands.push(DrawCommand {
                                graphics_pipeline: self.pipeline.clone(),
                                scissor: current_scizzor,
                                viewport: current_viewport.clone(),
                                vertex_buffer: vbuf,
                                descriptor_set: desc_cache.clone(),
                            });
                        }
                    }
                    // Draw an image whose texture data lies within the `image_map` at the
                    // given `id`.
                    mesh::Draw::Image(image_id, vert_range) => {
                        if vert_range.is_empty() {
                            continue;
                        }
                        if let Some(image) = image_map.get(&image_id) {
                            // ??????????? is there any reason to use self.tex_descs
                            /*
                            let tex_desc = self
                                .tex_descs
                                .next()
                                .add_sampled_image(
                                    ImageView::new(image.image_access.clone()).unwrap(),
                                    self.sampler.clone(),
                                ).unwrap()
                                .build()?;*/
                            let mut desc_set_builder = self.tex_descs.next();
                            desc_set_builder.add_sampled_image(
                                ImageView::new(image.image_access.clone()).unwrap(),
                                self.sampler.clone(),
                            )?;
                            let desc_image = Arc::new(desc_set_builder.build()?);
                            //let desc_image = Arc::new(tex_desc);
                            let verts = &self.mesh.vertices()[vert_range];
                            let verts = conv_vertex_buffer(verts);
                            let (vbuf, vbuf_fut) = ImmutableBuffer::from_iter(
                                verts.iter().cloned(),
                                BufferUsage::vertex_buffer(),
                                queue.clone(),
                            )?;
                            vbuf_fut
                                .then_signal_fence_and_flush()
                                .unwrap()
                                .wait(None)
                                .unwrap();
                            draw_commands.push(DrawCommand {
                                graphics_pipeline: self.pipeline.clone(),
                                scissor: current_scizzor,
                                viewport: current_viewport.clone(),
                                vertex_buffer: vbuf,
                                descriptor_set: desc_image,
                            });
                        }
                    }
                },
            }
        }
        Ok(draw_commands)
    }
pub fn draw ( & mut self , queue : Arc < Queue > , image_map : & image :: Map < Image > , viewport : [ f32 ; 4 ] , ) -> Result < Vec < DrawCommand > , DrawError > { let current_viewport = Viewport { origin : [ viewport [ 0 ] , viewport [ 1 ] ] , dimensions : [ viewport [ 2 ] - viewport [ 0 ] , viewport [ 3 ] - viewport [ 1 ] ] , depth_range : 0.0 .. 1.0 , } ; let mut current_scizzor = Scissor { origin : [ viewport [ 0 ] as u32 , viewport [ 1 ] as u32 ] , dimensions : [ ( viewport [ 2 ] - viewport [ 0 ] ) as u32 , ( viewport [ 3 ] - viewport [ 1 ] ) as u32 , ] , } ; let conv_scizzor = | s : mesh :: Scizzor | Scissor { origin : [ s . top_left [ 0 ] as u32 , s . top_left [ 1 ] as u32 ] , dimensions : s . dimensions , } ; // ?????????????????? is there any reason to use self.tex_descs let mut desc_set_builder = self . tex_descs . next ( ) ; desc_set_builder . add_sampled_image ( ImageView :: new ( self . glyph_cache_tex . clone ( ) ) . unwrap ( ) , self . sampler . clone ( ) , ) ? ; let desc_cache = Arc :: new ( desc_set_builder . build ( ) ? ) ; let commands = self . mesh . commands ( ) ; let mut draw_commands = vec ! [ ] ; for command in commands { match command { // Update the `scizzor` before continuing to draw. mesh :: Command :: Scizzor ( scizzor ) => current_scizzor = conv_scizzor ( scizzor ) , // Draw to the target with the given `draw` command. mesh :: Command :: Draw ( draw ) => match draw { // Draw text and plain 2D geometry. mesh :: Draw :: Plain ( vert_range ) => { if ! vert_range . is_empty ( ) { let verts = & self . mesh . vertices ( ) [ vert_range ] ; let verts = conv_vertex_buffer ( verts ) ; let ( vbuf , vbuf_fut ) = ImmutableBuffer :: < [ Vertex ] > :: from_iter ( verts . iter ( ) . cloned ( ) , BufferUsage :: vertex_buffer ( ) , queue . clone ( ) , ) ? ; vbuf_fut . then_signal_fence_and_flush ( ) . expect ( " " ) . wait ( None ) . unwrap ( ) ; draw_commands . push ( DrawCommand { graphics_pipeline : self . pipeline . clone ( ) , scissor : current_scizzor , viewport : current_viewport . clone ( ) , vertex_buffer : vbuf , descriptor_set : desc_cache . clone ( ) , } ) ; } } // Draw an image whose texture data lies within the `image_map` at the // given `id`. mesh :: Draw :: Image ( image_id , vert_range ) => { if vert_range . is_empty ( ) { continue ; } if let Some ( image ) = image_map . get ( & image_id ) { // ??????????? is there any reason to use self.tex_descs /*
                            let tex_desc = self
                                .tex_descs
                                .next()
                                .add_sampled_image(
                                    ImageView::new(image.image_access.clone()).unwrap(),
                                    self.sampler.clone(),
                                ).unwrap()
                                .build()?;*/ let mut desc_set_builder = self . tex_descs . next ( ) ; desc_set_builder . add_sampled_image ( ImageView :: new ( image . image_access . clone ( ) ) . unwrap ( ) , self . sampler . clone ( ) , ) ? ; let desc_image = Arc :: new ( desc_set_builder . build ( ) ? ) ; //let desc_image = Arc::new(tex_desc); let verts = & self . mesh . vertices ( ) [ vert_range ] ; let verts = conv_vertex_buffer ( verts ) ; let ( vbuf , vbuf_fut ) = ImmutableBuffer :: from_iter ( verts . iter ( ) . cloned ( ) , BufferUsage :: vertex_buffer ( ) , queue . clone ( ) , ) ? ; vbuf_fut . then_signal_fence_and_flush ( ) . unwrap ( ) . wait ( None ) . unwrap ( ) ; draw_commands . push ( DrawCommand { graphics_pipeline : self . pipeline . clone ( ) , scissor : current_scizzor , viewport : current_viewport . clone ( ) , vertex_buffer : vbuf , descriptor_set : desc_image , } ) ; } } } , } } Ok ( draw_commands ) }
Draws using the inner list of `Command`s to a list of `DrawCommand`s compatible with the
vulkano command buffer builders.
Draws using the inner list of ` Command ` s to a list of ` DrawCommand ` s compatible with the vulkano command buffer builders .
&mut self
queue
Arc<Queue>
image_map
&image::Map<Image>
viewport
[f32; 4]
&mut self
queue
Arc<Queue>
image_map
&image::Map<Image>
viewport
[f32; 4]