/// Draws a textured mesh with `draw` parameters.
Draws a textured mesh with `draw` parameters.
Draws a textured mesh with ` draw ` parameters .
pub fn draw(&mut self, cx: &Context, pass: &mut ArenaRenderPass, draw: MeshDraw) {
        let alloc = self
            .uniforms
            .allocate(cx, cx.pad_uniform_size(GpuDraw::std430_size_static() as _));
        let gpu_draw = GpuDraw::from(&draw);
        cx.queue.write_buffer(
            alloc.buffer.as_ref(),
            alloc.offset,
            gpu_draw.as_std430().as_bytes(),
        );
        let uniform_group = self.uniform_binds.get(
            cx,
            alloc.index as _,
            &wgpu::BindGroupDescriptor {
                label: None,
                layout: &self.uniform_layout,
                entries: &[wgpu::BindGroupEntry {
                    binding: 0,
                    resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
                        buffer: alloc.buffer.as_ref(),
                        offset: 0,
                        size: Some(NonZeroU64::new(GpuDraw::std430_size_static() as _).unwrap()),
                    }),
                }],
            },
        );
        let texture_group = self.texture_binds.get(
            cx,
            draw.texture.id(),
            &wgpu::BindGroupDescriptor {
                label: None,
                layout: &self.texture_layout,
                entries: &[wgpu::BindGroupEntry {
                    binding: 0,
                    resource: wgpu::BindingResource::TextureView(&draw.texture.view),
                }],
            },
        );
        pass.set_bind_group(self.uniform_slot, uniform_group, &[alloc.offset as u32]);
        pass.set_bind_group(self.texture_slot, texture_group, &[]);
        pass.set_vertex_buffer(0, draw.mesh.vertices.clone(), 0);
        pass.set_index_buffer(draw.mesh.indices.clone(), 0, wgpu::IndexFormat::Uint32);
        pass.draw_indexed(0..draw.mesh.index_count as u32, 0, 0..1);
    }
pub fn draw ( & mut self , cx : & Context , pass : & mut ArenaRenderPass , draw : MeshDraw ) { let alloc = self . uniforms . allocate ( cx , cx . pad_uniform_size ( GpuDraw :: std430_size_static ( ) as _ ) ) ; let gpu_draw = GpuDraw :: from ( & draw ) ; cx . queue . write_buffer ( alloc . buffer . as_ref ( ) , alloc . offset , gpu_draw . as_std430 ( ) . as_bytes ( ) , ) ; let uniform_group = self . uniform_binds . get ( cx , alloc . index as _ , & wgpu :: BindGroupDescriptor { label : None , layout : & self . uniform_layout , entries : & [ wgpu :: BindGroupEntry { binding : 0 , resource : wgpu :: BindingResource :: Buffer ( wgpu :: BufferBinding { buffer : alloc . buffer . as_ref ( ) , offset : 0 , size : Some ( NonZeroU64 :: new ( GpuDraw :: std430_size_static ( ) as _ ) . unwrap ( ) ) , } ) , } ] , } , ) ; let texture_group = self . texture_binds . get ( cx , draw . texture . id ( ) , & wgpu :: BindGroupDescriptor { label : None , layout : & self . texture_layout , entries : & [ wgpu :: BindGroupEntry { binding : 0 , resource : wgpu :: BindingResource :: TextureView ( & draw . texture . view ) , } ] , } , ) ; pass . set_bind_group ( self . uniform_slot , uniform_group , & [ alloc . offset as u32 ] ) ; pass . set_bind_group ( self . texture_slot , texture_group , & [ ] ) ; pass . set_vertex_buffer ( 0 , draw . mesh . vertices . clone ( ) , 0 ) ; pass . set_index_buffer ( draw . mesh . indices . clone ( ) , 0 , wgpu :: IndexFormat :: Uint32 ) ; pass . draw_indexed ( 0 .. draw . mesh . index_count as u32 , 0 , 0 .. 1 ) ; }
Draws a textured mesh with `draw` parameters.
Draws a textured mesh with ` draw ` parameters .
&mut self
cx
&Context
pass
&mut ArenaRenderPass
draw
MeshDraw