MCPcopy Create free account
hub / github.com/AryanpurTech/BlueEngine / build_vertex_buffer

Method build_vertex_buffer

crates/blue_engine_core/src/definition.rs:462–488  ·  view source on GitHub ↗

Creates a new vertex buffer and indices

(
        &mut self,
        vertices: &Vec<Vertex>,
        indices: &Vec<UnsignedIntType>,
    )

Source from the content-addressed store, hash-verified

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 {

Callers 2

newMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected