(&mut self, target: &impl Target)
| 117 | } |
| 118 | |
| 119 | pub fn draw(&mut self, target: &impl Target) { |
| 120 | let mut index = 0; |
| 121 | |
| 122 | for mut batch in self.batches.drain(..) { |
| 123 | let texture = batch.texture.as_ref().unwrap_or(&self.default_texture); |
| 124 | |
| 125 | while batch.sprites > 0 { |
| 126 | let num_sprites = usize::min(batch.sprites, MAX_SPRITES); |
| 127 | |
| 128 | let sprites = &self.sprites[index..index + num_sprites]; |
| 129 | let vertices = bytemuck::cast_slice(sprites); |
| 130 | |
| 131 | self.mesh.set_vertices(vertices); |
| 132 | |
| 133 | self.mesh.raw.gfx.draw(RenderPass { |
| 134 | target, |
| 135 | |
| 136 | mesh: &self.mesh, |
| 137 | texture, |
| 138 | shader: &self.default_shader, |
| 139 | |
| 140 | index_start: 0, |
| 141 | index_count: num_sprites * 6, |
| 142 | }); |
| 143 | |
| 144 | index += num_sprites; |
| 145 | batch.sprites -= num_sprites; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | self.sprites.clear(); |
| 150 | self.batches.push(Batch::default()); |
| 151 | self.matrices.clear(); |
| 152 | } |
| 153 | |
| 154 | pub fn push_matrix(&mut self, matrix: Mat3) { |
| 155 | // TODO: Support relative transforms |
nothing calls this directly
no test coverage detected