mesh correct and textures too
This commit is contained in:
parent
31d4a139ef
commit
8afb2d2a3c
5 changed files with 9 additions and 5 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue