mesh correct and textures too

This commit is contained in:
zomseffen 2024-04-27 08:06:18 +02:00
parent 31d4a139ef
commit 8afb2d2a3c
5 changed files with 9 additions and 5 deletions

View file

@ -130,7 +130,7 @@ pub unsafe fn create_index_buffer(
device: &Device,
data: &mut app_data::AppData,
) -> Result<()> {
let size = (size_of::<u16>() * data.indices.len()) as u64;
let size = (size_of::<u32>() * data.indices.len()) as u64;
let (staging_buffer, staging_buffer_memory) = create_buffer(
instance,

View file

@ -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,

View file

@ -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,

View file

@ -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(

View file

@ -41,14 +41,14 @@ impl Vertex {
.binding(0)
.location(1)
.format(vk::Format::R32G32B32_SFLOAT)
.offset(size_of::<Vec2>() as u32)
.offset(size_of::<Vec3>() as u32)
.build();
let tex_coord = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(2)
.format(vk::Format::R32G32_SFLOAT)
.offset((size_of::<Vec2>() + size_of::<Vec3>()) as u32)
.offset((size_of::<Vec3>() + size_of::<Vec3>()) as u32)
.build();
[pos, color, tex_coord]
}