summary refs log tree commit diff
path: root/src/shader_data.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-07-18 04:10:00 -0700
committerIrene Knapp <ireneista@irenes.space>2026-07-18 04:10:00 -0700
commitcbfe9b855c11b1ef603b7212c244e089b4461753 (patch)
tree4ae0200ff692fffb19d637caf9720e4643d8c844 /src/shader_data.rs
parent0371c8f086008d604dddfe92d021f8ecfe398436 (diff)
draw a second square
in order to test the depth buffer, which does not yet exist

Force-Push: yes
Change-Id: Ibb4c279ff8b83ad9c0c37897f623631c4e342fb0
Diffstat (limited to 'src/shader_data.rs')
-rw-r--r--src/shader_data.rs39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/shader_data.rs b/src/shader_data.rs
index 404d5fb..bd7ff82 100644
--- a/src/shader_data.rs
+++ b/src/shader_data.rs
@@ -5,24 +5,35 @@ use std::mem::size_of;
 use vulkanalia::vk::{ self, HasBuilder };
 
 
-pub static VERTICES: [Vertex<f32>; 4] = [
-  Vertex::new(Vec2::new(-0.5, -0.5), Vec3::new(1.0, 0.0, 0.0),
+pub static VERTICES: [Vertex<f32>; 8] = [
+  Vertex::new(Vec3::new(-0.5, -0.5,  0.0), 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),
+  Vertex::new(Vec3::new( 0.5, -0.5,  0.0), 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),
+  Vertex::new(Vec3::new( 0.5,  0.5,  0.0), 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),
+  Vertex::new(Vec3::new(-0.5,  0.5,  0.0), Vec3::new(1.0, 1.0, 1.0),
+              Vec2::new(1.0, 1.0)),
+  Vertex::new(Vec3::new(-0.5, -0.5,  0.5), Vec3::new(1.0, 0.0, 0.0),
+              Vec2::new(1.0, 0.0)),
+  Vertex::new(Vec3::new( 0.5, -0.5,  0.5), Vec3::new(0.0, 1.0, 0.0),
+              Vec2::new(0.0, 0.0)),
+  Vertex::new(Vec3::new( 0.5,  0.5,  0.5), Vec3::new(0.0, 0.0, 1.0),
+              Vec2::new(0.0, 1.0)),
+  Vertex::new(Vec3::new(-0.5,  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];
+pub const INDICES: &[u16] = &[
+  0, 1, 2, 2, 3, 0,
+  4, 5, 6, 6, 7, 4,
+];
 
 
 #[repr(C)]
 #[derive(Clone, Debug)]
 pub struct Vertex<T: Copy> {
-  pub position: Vec2<T>,
+  pub position: Vec3<T>,
   pub color: Vec3<T>,
   pub texture_coordinates: Vec2<T>,
 }
@@ -37,7 +48,7 @@ pub struct UniformBlock<T: Copy> {
 }
 
 impl<T: Copy> Vertex<T> {
-  const fn new(position: Vec2<T>, color: Vec3<T>,
+  const fn new(position: Vec3<T>, color: Vec3<T>,
                texture_coordinates: Vec2<T>)
       -> Self
   {
@@ -55,25 +66,29 @@ impl<T: Copy> Vertex<T> {
   pub fn attribute_descriptions()
       -> [vk::VertexInputAttributeDescription; 3]
   {
+    let mut offset: usize = 0;
+
     let position = vk::VertexInputAttributeDescription::builder()
             .binding(0)
             .location(0)
-            .format(vk::Format::R32G32_SFLOAT)
-            .offset(0)
+            .format(vk::Format::R32G32B32_SFLOAT)
+            .offset(offset as u32)
             .build();
+    offset += size_of::<Vec3<f32>>();
 
     let color = vk::VertexInputAttributeDescription::builder()
             .binding(0)
             .location(1)
             .format(vk::Format::R32G32B32_SFLOAT)
-            .offset(size_of::<Vec2<f32>>() as u32)
+            .offset(offset as u32)
             .build();
+    offset += size_of::<Vec3<f32>>();
 
     let texture_coordinates = vk::VertexInputAttributeDescription::builder()
             .binding(0)
             .location(2)
             .format(vk::Format::R32G32_SFLOAT)
-            .offset((size_of::<Vec2<f32>>() + size_of::<Vec3<f32>>()) as u32)
+            .offset(offset as u32)
             .build();
 
     [position, color, texture_coordinates]