This commit is contained in:
parent
c0367144a6
commit
dd8a5a97ea
9 changed files with 83 additions and 13 deletions
33
src/vulkan/vertex.rs
Normal file
33
src/vulkan/vertex.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use ash::vk;
|
||||
use std::mem::offset_of;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Vertex {
|
||||
pub position: [f32; 2],
|
||||
pub color: [f32; 3],
|
||||
}
|
||||
|
||||
impl Vertex {
|
||||
pub fn get_binding_description() -> vk::VertexInputBindingDescription {
|
||||
vk::VertexInputBindingDescription::default()
|
||||
.binding(0)
|
||||
.stride(size_of::<Self>() as u32)
|
||||
.input_rate(vk::VertexInputRate::VERTEX)
|
||||
}
|
||||
|
||||
pub fn get_attribute_descriptions() -> [vk::VertexInputAttributeDescription; 2] {
|
||||
let position_attribute = vk::VertexInputAttributeDescription::default()
|
||||
.binding(0)
|
||||
.location(0)
|
||||
.format(vk::Format::R32G32_SFLOAT)
|
||||
.offset(offset_of!(Vertex, position) as u32);
|
||||
|
||||
let color_attribute = vk::VertexInputAttributeDescription::default()
|
||||
.binding(0)
|
||||
.location(1)
|
||||
.format(vk::Format::R32G32B32_SFLOAT)
|
||||
.offset(offset_of!(Vertex, color) as u32);
|
||||
|
||||
[position_attribute, color_attribute]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue