pub fn prepare_vertices(device: &VkDevice) -> VkResult<(VertexBuffer, IndexBuffer)> {

    let vertices_data = [
        Vertex { position: [ 1.0,  1.0, 0.0], color: [1.0, 0.0, 0.0] },
        Vertex { position: [-1.0,  1.0, 0.0], color: [0.0, 1.0, 0.0] },
        Vertex { position: [ 0.0, -1.0, 0.0], color: [0.0, 0.0, 1.0] },
    ];
    let vertices = allocate_buffer(device, &vertices_data, vk::BufferUsageFlags::VERTEX_BUFFER)?;

    let indices_data = [0, 1, 2_u32];
    let indices = allocate_buffer(device, &indices_data, vk::BufferUsageFlags::INDEX_BUFFER)?;

    transfer_staging_data(device, &vertices, &indices)?;

    device.discard(vertices.staging_buffer);
    device.discard(vertices.staging_memory);

    device.discard(indices.staging_buffer);
    device.discard(indices.staging_memory);

    let vertex_buffer = VertexBuffer {
        buffer: vertices.target_buffer,
        memory: vertices.target_memory,
    };

    let index_buffer = IndexBuffer {
        buffer: indices.target_buffer,
        memory: indices.target_memory,
        count: indices_data.len() as _,
    };

    Ok((vertex_buffer, index_buffer))
}
// Prepare vertices buffer and index buffer for an indexed triangle.
Prepare vertices buffer and index buffer for an indexed triangle.
Prepare vertices buffer and index buffer for an indexed triangle .
pub fn prepare_vertices(device: &VkDevice) -> VkResult<(VertexBuffer, IndexBuffer)> {
    let vertices_data = [
        Vertex { position: [ 1.0,  1.0, 0.0], color: [1.0, 0.0, 0.0] },
        Vertex { position: [-1.0,  1.0, 0.0], color: [0.0, 1.0, 0.0] },
        Vertex { position: [ 0.0, -1.0, 0.0], color: [0.0, 0.0, 1.0] },
    ];
    let vertices = allocate_buffer(device, &vertices_data, vk::BufferUsageFlags::VERTEX_BUFFER)?;
    let indices_data = [0, 1, 2_u32];
    let indices = allocate_buffer(device, &indices_data, vk::BufferUsageFlags::INDEX_BUFFER)?;
    transfer_staging_data(device, &vertices, &indices)?;
    device.discard(vertices.staging_buffer);
    device.discard(vertices.staging_memory);
    device.discard(indices.staging_buffer);
    device.discard(indices.staging_memory);
    let vertex_buffer = VertexBuffer {
        buffer: vertices.target_buffer,
        memory: vertices.target_memory,
    };
    let index_buffer = IndexBuffer {
        buffer: indices.target_buffer,
        memory: indices.target_memory,
        count: indices_data.len() as _,
    };
    Ok((vertex_buffer, index_buffer))
}
pub fn prepare_vertices ( device : & VkDevice ) -> VkResult < ( VertexBuffer , IndexBuffer ) > { let vertices_data = [ Vertex { position : [ 1.0 , 1.0 , 0.0 ] , color : [ 1.0 , 0.0 , 0.0 ] } , Vertex { position : [ - 1.0 , 1.0 , 0.0 ] , color : [ 0.0 , 1.0 , 0.0 ] } , Vertex { position : [ 0.0 , - 1.0 , 0.0 ] , color : [ 0.0 , 0.0 , 1.0 ] } , ] ; let vertices = allocate_buffer ( device , & vertices_data , vk :: BufferUsageFlags :: VERTEX_BUFFER ) ? ; let indices_data = [ 0 , 1 , 2_u32 ] ; let indices = allocate_buffer ( device , & indices_data , vk :: BufferUsageFlags :: INDEX_BUFFER ) ? ; transfer_staging_data ( device , & vertices , & indices ) ? ; device . discard ( vertices . staging_buffer ) ; device . discard ( vertices . staging_memory ) ; device . discard ( indices . staging_buffer ) ; device . discard ( indices . staging_memory ) ; let vertex_buffer = VertexBuffer { buffer : vertices . target_buffer , memory : vertices . target_memory , } ; let index_buffer = IndexBuffer { buffer : indices . target_buffer , memory : indices . target_memory , count : indices_data . len ( ) as _ , } ; Ok ( ( vertex_buffer , index_buffer ) ) }
Prepare vertices buffer and index buffer for an indexed triangle.
Prepare vertices buffer and index buffer for an indexed triangle .
device
&VkDevice
device
&VkDevice