Creates a new vertex buffer and indices
(
&mut self,
vertices: &Vec<Vertex>,
indices: &Vec<UnsignedIntType>,
)
| 460 | |
| 461 | /// Creates a new vertex buffer and indices |
| 462 | pub fn build_vertex_buffer( |
| 463 | &mut self, |
| 464 | vertices: &Vec<Vertex>, |
| 465 | indices: &Vec<UnsignedIntType>, |
| 466 | ) -> VertexBuffers { |
| 467 | let vertex_buffer = self |
| 468 | .device |
| 469 | .create_buffer_init(&wgpu::util::BufferInitDescriptor { |
| 470 | label: Some("Vertex Buffer"), |
| 471 | contents: bytemuck::cast_slice(vertices.as_slice()), |
| 472 | usage: wgpu::BufferUsages::VERTEX, |
| 473 | }); |
| 474 | |
| 475 | let index_buffer = self |
| 476 | .device |
| 477 | .create_buffer_init(&wgpu::util::BufferInitDescriptor { |
| 478 | label: Some("Index Buffer"), |
| 479 | contents: bytemuck::cast_slice(indices.as_slice()), |
| 480 | usage: wgpu::BufferUsages::INDEX, |
| 481 | }); |
| 482 | |
| 483 | VertexBuffers { |
| 484 | vertex_buffer, |
| 485 | index_buffer, |
| 486 | length: indices.len() as u32, |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | /// Creates a new instance buffer for the object |
| 491 | pub fn build_instance(&self, instance_data: Vec<InstanceRaw>) -> wgpu::Buffer { |
no outgoing calls
no test coverage detected