diff --git a/src/.bin/shader.frag.spv b/src/.bin/shader.frag.spv index 8ac5422..226a1d5 100644 Binary files a/src/.bin/shader.frag.spv and b/src/.bin/shader.frag.spv differ diff --git a/src/.bin/shader.vert.spv b/src/.bin/shader.vert.spv index 3ccffd5..dd48e11 100644 Binary files a/src/.bin/shader.vert.spv and b/src/.bin/shader.vert.spv differ diff --git a/src/app.rs b/src/app.rs index 2bc4fbc..e557417 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3,17 +3,15 @@ use wgpu::util::DeviceExt; use crate::vertex::Vertex; const VERTICES: &[Vertex] = &[ - Vertex { position: [-0.0868241, 0.49240386, 0.0], color: [1.0, 0.0, 0.0] }, // A - Vertex { position: [-0.49513406, 0.06958647, 0.0], color: [0.0, 1.0, 0.0] }, // B - Vertex { position: [-0.21918549, -0.44939706, 0.0], color: [0.0, 0.0, 1.0] }, // C - Vertex { position: [0.35966998, -0.3473291, 0.0], color: [0.0, 0.5, 0.5] }, // D - Vertex { position: [0.44147372, 0.2347359, 0.0],color: [0.5, 0.5, 0.0] }, // E + Vertex { position: [-0.5, 0.5, 0.0], uv: [0.0, 1.0] }, + Vertex { position: [ 0.5, 0.5, 0.0], uv: [1.0, 1.0] }, + Vertex { position: [ 0.5,-0.5, 0.0], uv: [1.0, 0.0] }, + Vertex { position: [-0.5,-0.5, 0.0], uv: [0.0, 0.0] }, ]; const INDICES: &[u16] = &[ - 0, 1, 4, - 1, 2, 4, - 2, 3, 4, + 0, 1, 3, + 3, 1, 2 ]; pub struct App { @@ -91,7 +89,7 @@ impl App { let prim_state = wgpu::PrimitiveState { // primitive topology: wgpu::PrimitiveTopology::TriangleList, strip_index_format: None, - front_face: wgpu::FrontFace::Ccw, + front_face: wgpu::FrontFace::Cw, cull_mode: wgpu::CullMode::Back, polygon_mode: wgpu::PolygonMode::Fill, }; @@ -131,6 +129,7 @@ impl App { ); // Save values in app + println!("Initialized"); Self { surface, device, queue, swapchain_desc, swapchain, pipeline, vertex_buffer, index_buffer } } diff --git a/src/shader.frag b/src/shader.frag index 9f09429..b4ca97f 100644 --- a/src/shader.frag +++ b/src/shader.frag @@ -1,10 +1,10 @@ // shader.frag #version 450 -layout(location=0) in vec3 vert_color; +layout(location=0) in vec2 vert_uv; layout(location=0) out vec4 frag_color; void main() { - frag_color = vec4(vert_color, 1.0); + frag_color = vec4(vert_uv, 0.0, 1.0); } \ No newline at end of file diff --git a/src/shader.vert b/src/shader.vert index ecf2291..3731eb2 100644 --- a/src/shader.vert +++ b/src/shader.vert @@ -1,12 +1,12 @@ #version 450 layout(location=0) in vec3 in_position; -layout(location=1) in vec3 in_color; -layout(location=0) out vec3 vert_color; +layout(location=1) in vec2 in_uv; +layout(location=0) out vec2 vert_uv; void main() { - vert_color = in_color; + vert_uv = in_uv; gl_Position = vec4(in_position, 1.0); } \ No newline at end of file diff --git a/src/vertex.rs b/src/vertex.rs index 8f26feb..480aaac 100644 --- a/src/vertex.rs +++ b/src/vertex.rs @@ -4,7 +4,7 @@ #[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)] pub struct Vertex { pub position: [f32; 3], - pub color: [f32; 3], + pub uv: [f32; 2], } impl Vertex { @@ -23,7 +23,7 @@ impl Vertex { wgpu::VertexAttribute { offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress, shader_location: 1, - format: wgpu::VertexFormat::Float3, + format: wgpu::VertexFormat::Float2, } ] }