From 40bd889e67d6f9fb4ce837fcda4ddf5a34c54b47 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sat, 18 Jul 2026 03:15:56 -0700 Subject: draw the image wow yay :) Force-Push: yes Change-Id: I7053ec3a7ed7b46e9c9d1260fd0f73b398b798af --- src/linear_algebra.rs | 53 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 19 deletions(-) (limited to 'src/linear_algebra.rs') diff --git a/src/linear_algebra.rs b/src/linear_algebra.rs index 0051fa8..08e9306 100644 --- a/src/linear_algebra.rs +++ b/src/linear_algebra.rs @@ -30,10 +30,14 @@ impl Real for f32 { pub static VERTICES: [Vertex; 4] = [ - Vertex::new(Vec2::new(-0.5, -0.5), Vec3::new(1.0, 0.0, 0.0)), - Vertex::new(Vec2::new( 0.5, -0.5), Vec3::new(0.0, 1.0, 0.0)), - Vertex::new(Vec2::new( 0.5, 0.5), Vec3::new(0.0, 0.0, 1.0)), - Vertex::new(Vec2::new(-0.5, 0.5), Vec3::new(1.0, 1.0, 1.0)), + Vertex::new(Vec2::new(-0.5, -0.5), Vec3::new(1.0, 0.0, 0.0), + Vec2::new(1.0, 0.0)), + Vertex::new(Vec2::new( 0.5, -0.5), Vec3::new(0.0, 1.0, 0.0), + Vec2::new(0.0, 0.0)), + Vertex::new(Vec2::new( 0.5, 0.5), Vec3::new(0.0, 0.0, 1.0), + Vec2::new(0.0, 1.0)), + Vertex::new(Vec2::new(-0.5, 0.5), Vec3::new(1.0, 1.0, 1.0), + Vec2::new(1.0, 1.0)), ]; pub const INDICES: &[u16] = &[0, 1, 2, 2, 3, 0]; @@ -621,6 +625,7 @@ impl Transformation { pub struct Vertex { pub position: Vec2, pub color: Vec3, + pub texture_coordinates: Vec2, } #[repr(C)] @@ -633,8 +638,11 @@ pub struct UniformBlock { } impl Vertex { - const fn new(position: Vec2, color: Vec3) -> Self { - Self { position, color } + const fn new(position: Vec2, color: Vec3, + texture_coordinates: Vec2) + -> Self + { + Self { position, color, texture_coordinates } } pub fn binding_description() -> vk::VertexInputBindingDescription { @@ -646,23 +654,30 @@ impl Vertex { } pub fn attribute_descriptions() - -> [vk::VertexInputAttributeDescription; 2] + -> [vk::VertexInputAttributeDescription; 3] { let position = vk::VertexInputAttributeDescription::builder() - .binding(0) - .location(0) - .format(vk::Format::R32G32_SFLOAT) - .offset(0) - .build(); + .binding(0) + .location(0) + .format(vk::Format::R32G32_SFLOAT) + .offset(0) + .build(); let color = vk::VertexInputAttributeDescription::builder() - .binding(0) - .location(1) - .format(vk::Format::R32G32B32_SFLOAT) - .offset(size_of::>() as u32) - .build(); - - [position, color] + .binding(0) + .location(1) + .format(vk::Format::R32G32B32_SFLOAT) + .offset(size_of::>() as u32) + .build(); + + let texture_coordinates = vk::VertexInputAttributeDescription::builder() + .binding(0) + .location(2) + .format(vk::Format::R32G32_SFLOAT) + .offset((size_of::>() + size_of::>()) as u32) + .build(); + + [position, color, texture_coordinates] } } -- cgit 1.4.1