From e0795b55b759a102638c807a6e8a237a5eec9a7c Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sun, 21 Feb 2016 11:02:51 +0100 Subject: [PATCH] Fix teapot appearance --- vulkano/examples/teapot.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vulkano/examples/teapot.rs b/vulkano/examples/teapot.rs index 0393fa14..ec06ddff 100644 --- a/vulkano/examples/teapot.rs +++ b/vulkano/examples/teapot.rs @@ -54,6 +54,15 @@ fn main() { }; + let cb_pool = vulkano::command_buffer::CommandBufferPool::new(&device, &queue.lock().unwrap().family()) + .expect("failed to create command buffer pool"); + + + let depth_buffer = vulkano::image::Image::::new(&device, &vulkano::image::Usage::all(), + vulkano::memory::DeviceLocal, &queue, + images[0].dimensions(), (), 1).unwrap(); + let depth_buffer = depth_buffer.transition(vulkano::image::Layout::DepthStencilAttachmentOptimal, &cb_pool, &mut queue.lock().unwrap()); + let vertex_buffer = vulkano::buffer::Buffer::<[teapot::Vertex], _> ::array(&device, teapot::VERTICES.len(), &vulkano::buffer::Usage::all(), @@ -95,8 +104,8 @@ fn main() { // note: this teapot was meant for OpenGL where the origin is at the lower left // instead the origin is at the upper left in vulkan, so we reverse the Y axis - let proj = cgmath::perspective(cgmath::rad(3.141592 / 2.0), { let d = images[0].dimensions(); d[1] as f32 / d[0] as f32 }, 0.01, 100.0); - let view = cgmath::Matrix4::look_at(cgmath::Point3::new(-2.0, 0.0, 0.4), cgmath::Point3::new(0.0, 0.0, 0.0), cgmath::Vector3::new(0.0, -1.0, 0.0)); + let proj = cgmath::perspective(cgmath::rad(3.141592 / 2.0), { let d = images[0].dimensions(); d[0] as f32 / d[1] as f32 }, 0.01, 100.0); + let view = cgmath::Matrix4::look_at(cgmath::Point3::new(0.2, 0.2, 1.0), cgmath::Point3::new(0.0, 0.0, 0.0), cgmath::Vector3::new(0.0, -1.0, 0.0)); let scale = cgmath::Matrix4::from_scale(0.01); let uniform_buffer = vulkano::buffer::Buffer::<([[f32; 4]; 4], [[f32; 4]; 4]), _> @@ -114,9 +123,6 @@ fn main() { mod fs { include!{concat!(env!("OUT_DIR"), "/examples-teapot_fs.rs")} } let fs = fs::TeapotShader::load(&device).expect("failed to create shader module"); - let cb_pool = vulkano::command_buffer::CommandBufferPool::new(&device, &queue.lock().unwrap().family()) - .expect("failed to create command buffer pool"); - let images = images.into_iter().map(|image| { let image = image.transition(vulkano::image::Layout::PresentSrc, &cb_pool, &mut queue.lock().unwrap()).unwrap();