texture loading and depth buffer

This commit is contained in:
zomseffen 2024-04-26 17:48:49 +02:00
parent 0137d21406
commit f6276bfdf6
14 changed files with 695 additions and 159 deletions

View file

@ -10,13 +10,14 @@ type Vec3 = cgmath::Vector3<f32>;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Vertex {
pub pos: Vec2,
pub pos: Vec3,
pub color: Vec3,
pub tex_coord: Vec2,
}
impl Vertex {
pub const fn new(pos: Vec2, color: Vec3) -> Self {
Self { pos, color }
pub const fn new(pos: Vec3, color: Vec3, tex_coord: Vec2) -> Self {
Self { pos, color, tex_coord }
}
pub fn binding_description() -> vk::VertexInputBindingDescription {
@ -27,11 +28,11 @@ impl Vertex {
.build()
}
pub fn attribute_descriptions() -> [vk::VertexInputAttributeDescription; 2] {
pub fn attribute_descriptions() -> [vk::VertexInputAttributeDescription; 3] {
let pos = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(0)
.format(vk::Format::R32G32_SFLOAT)
.format(vk::Format::R32G32B32_SFLOAT)
.offset(0)
.build();
@ -41,6 +42,13 @@ impl Vertex {
.format(vk::Format::R32G32B32_SFLOAT)
.offset(size_of::<Vec2>() as u32)
.build();
[pos, color]
let tex_coord = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(2)
.format(vk::Format::R32G32_SFLOAT)
.offset((size_of::<Vec2>() + size_of::<Vec3>()) as u32)
.build();
[pos, color, tex_coord]
}
}