Skip to content

Commit

Permalink
fixing clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-r-thomas committed May 13, 2024
1 parent f6031e2 commit 3143b37
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions examples/render_wgpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ impl<'a> WgpuExample {
.formats
.iter()
.copied()
.filter(|f| f.is_srgb())
.next()
.find(|f| f.is_srgb())
.unwrap_or(surface_caps.formats[0]);
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
Expand Down Expand Up @@ -144,31 +143,27 @@ impl WindowHandler for WgpuExample {
fn on_event(
&mut self, _window: &mut baseview::Window, event: baseview::Event,
) -> baseview::EventStatus {
match event {
baseview::Event::Mouse(MouseEvent::CursorMoved { position, modifiers: _ }) => {
let center_x: f32 = (position.x as f32 - 256.0) / 256.0;
let center_y: f32 = (256.0 - position.y as f32) / 256.0;
let vertices = &[
Vertex { position: [center_x, center_y + 0.25, 0.0], color: [1.0, 0.0, 0.0] },
Vertex {
position: [center_x - 0.25, center_y - 0.25, 0.0],
color: [0.0, 1.0, 0.0],
},
Vertex {
position: [center_x + 0.25, center_y - 0.25, 0.0],
color: [0.0, 0.0, 1.0],
},
];
let vertex_buffer =
self.device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::cast_slice(vertices),
usage: wgpu::BufferUsages::VERTEX,
});

self.vertex_buffer = vertex_buffer;
}
_ => {}
if let baseview::Event::Mouse(MouseEvent::CursorMoved { position, modifiers: _ }) = event {
let center_x: f32 = (position.x as f32 - 256.0) / 256.0;
let center_y: f32 = (256.0 - position.y as f32) / 256.0;
let vertices = &[
Vertex { position: [center_x, center_y + 0.25, 0.0], color: [1.0, 0.0, 0.0] },
Vertex {
position: [center_x - 0.25, center_y - 0.25, 0.0],
color: [0.0, 1.0, 0.0],
},
Vertex {
position: [center_x + 0.25, center_y - 0.25, 0.0],
color: [0.0, 0.0, 1.0],
},
];
let vertex_buffer = self.device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::cast_slice(vertices),
usage: wgpu::BufferUsages::VERTEX,
});

self.vertex_buffer = vertex_buffer;
}
baseview::EventStatus::Captured
}
Expand Down

0 comments on commit 3143b37

Please sign in to comment.