From 8afb2d2a3c1b5abafbcee76275a8537d0d5d4666 Mon Sep 17 00:00:00 2001 From: zomseffen Date: Sat, 27 Apr 2024 08:06:18 +0200 Subject: [PATCH] mesh correct and textures too --- src/buffer.rs | 2 +- src/command_buffer.rs | 2 +- src/image.rs | 4 ++++ src/main.rs | 2 +- src/vertex.rs | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 4bb92a2..051cea8 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -130,7 +130,7 @@ pub unsafe fn create_index_buffer( device: &Device, data: &mut app_data::AppData, ) -> Result<()> { - let size = (size_of::() * data.indices.len()) as u64; + let size = (size_of::() * data.indices.len()) as u64; let (staging_buffer, staging_buffer_memory) = create_buffer( instance, diff --git a/src/command_buffer.rs b/src/command_buffer.rs index a2cbade..1ea5e17 100644 --- a/src/command_buffer.rs +++ b/src/command_buffer.rs @@ -70,7 +70,7 @@ pub unsafe fn create_command_buffers(device: &Device, data: &mut app_data::AppDa *command_buffer, vk::PipelineBindPoint::GRAPHICS, data.pipeline); device.cmd_bind_vertex_buffers(*command_buffer, 0, &[data.vertex_buffer], &[0]); - device.cmd_bind_index_buffer(*command_buffer, data.index_buffer, 0, vk::IndexType::UINT16); + device.cmd_bind_index_buffer(*command_buffer, data.index_buffer, 0, vk::IndexType::UINT32); device.cmd_bind_descriptor_sets( *command_buffer, diff --git a/src/image.rs b/src/image.rs index 9da5d33..770d886 100644 --- a/src/image.rs +++ b/src/image.rs @@ -29,6 +29,10 @@ pub unsafe fn create_texture_image( let size = reader.info().raw_bytes() as u64; let (width, height) = reader.info().size(); + if width != 1024 || height != 1024 || reader.info().color_type != png::ColorType::Rgba { + panic!("Invalid texture image (use https://kylemayes.github.io/vulkanalia/images/viking_room.png)."); + } + let (staging_buffer, staging_buffer_memory) = buffer::create_buffer( instance, device, diff --git a/src/main.rs b/src/main.rs index 34e819b..0e62f84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -307,7 +307,7 @@ impl App { let model = buffer::Mat4::from_axis_angle( vec3(0.0, 0.0, 1.0), - cgmath::Deg(90.0) * time + cgmath::Deg(90.0) * 0.0 //time ); let view = buffer::Mat4::look_at_rh( diff --git a/src/vertex.rs b/src/vertex.rs index d8d80d8..8038561 100644 --- a/src/vertex.rs +++ b/src/vertex.rs @@ -41,14 +41,14 @@ impl Vertex { .binding(0) .location(1) .format(vk::Format::R32G32B32_SFLOAT) - .offset(size_of::() as u32) + .offset(size_of::() as u32) .build(); let tex_coord = vk::VertexInputAttributeDescription::builder() .binding(0) .location(2) .format(vk::Format::R32G32_SFLOAT) - .offset((size_of::() + size_of::()) as u32) + .offset((size_of::() + size_of::()) as u32) .build(); [pos, color, tex_coord] }