diff --git a/gfx-examples/src/cube.rs b/gfx-examples/src/cube.rs index f1bd1c3228..4fb56c911d 100644 --- a/gfx-examples/src/cube.rs +++ b/gfx-examples/src/cube.rs @@ -67,6 +67,7 @@ fn create_vertices() -> (Vec, Vec) { struct Cube { vertex_buf: wgpu::Buffer, index_buf: wgpu::Buffer, + index_count: usize, bind_group: wgpu::BindGroup, pipeline: wgpu::RenderPipeline, } @@ -185,7 +186,7 @@ impl fw::Example for Cube { ); let mx_total = mx_projection * mx_view; let mx_raw: &[f32; 16] = mx_total.as_ref(); - vertex_buf.set_sub_data(0, fw::cast_slice(&mx_raw[..])); + uniform_buf.set_sub_data(0, fw::cast_slice(&mx_raw[..])); } // Create bind group @@ -269,6 +270,7 @@ impl fw::Example for Cube { Cube { vertex_buf, index_buf, + index_count: index_data.len(), bind_group, pipeline, } @@ -293,7 +295,7 @@ impl fw::Example for Cube { rpass.set_bind_group(0, &self.bind_group); rpass.set_index_buffer(&self.index_buf, 0); rpass.set_vertex_buffers(&[(&self.vertex_buf, 0)]); - rpass.draw(0..3, 0..1); + rpass.draw_indexed(0 .. self.index_count as u32, 0, 0..1); rpass.end_pass(); } @@ -304,5 +306,5 @@ impl fw::Example for Cube { } fn main() { - fw::run::(); + fw::run::("cube"); } diff --git a/gfx-examples/src/framework.rs b/gfx-examples/src/framework.rs index cdceac1750..08727e496b 100644 --- a/gfx-examples/src/framework.rs +++ b/gfx-examples/src/framework.rs @@ -44,7 +44,7 @@ pub trait Example { fn render(&mut self, frame: &wgpu::SwapChainOutput, device: &mut wgpu::Device); } -pub fn run() { +pub fn run(title: &str) { use self::wgpu_native::winit::{ Event, ElementState, EventsLoop, KeyboardInput, Window, WindowEvent, VirtualKeyCode }; @@ -67,6 +67,7 @@ pub fn run() { info!("Initializing the window..."); let mut events_loop = EventsLoop::new(); let window = Window::new(&events_loop).unwrap(); + window.set_title(title); let size = window .get_inner_size() .unwrap()