1
0
Fork 0

Fix compiler and clippy warnings

This commit is contained in:
Adrian Hedqvist 2020-10-10 11:52:38 +02:00
parent 129619bb3d
commit 003338b828
3 changed files with 17 additions and 15 deletions

View file

@ -15,7 +15,7 @@ impl Camera {
let view = cgmath::Matrix4::look_at(self.eye, self.target, self.up); let view = cgmath::Matrix4::look_at(self.eye, self.target, self.up);
let proj = cgmath::perspective(cgmath::Deg(self.fovy), self.aspect, self.znear, self.zfar); let proj = cgmath::perspective(cgmath::Deg(self.fovy), self.aspect, self.znear, self.zfar);
return proj * view; proj * view
} }
} }

View file

@ -35,14 +35,16 @@ fn main() {
if !state.input(event) { if !state.input(event) {
match event { match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::KeyboardInput { input, .. } => match input { WindowEvent::KeyboardInput { input, .. } => {
KeyboardInput { if let KeyboardInput {
state: ElementState::Pressed, state: ElementState::Pressed,
virtual_keycode: Some(VirtualKeyCode::Escape), virtual_keycode: Some(VirtualKeyCode::Escape),
.. ..
} => *control_flow = ControlFlow::Exit, } = input
_ => {} {
}, *control_flow = ControlFlow::Exit
}
}
WindowEvent::Resized(physical_size) => { WindowEvent::Resized(physical_size) => {
state.resize(*physical_size); state.resize(*physical_size);
} }
@ -68,7 +70,7 @@ fn main() {
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
struct Uniforms { struct Uniforms {
view_position: cgmath::Vector4<f32>, view_position: cgmath::Vector4<f32>,
view_proj: cgmath::Matrix4<f32>, view_proj: Mat4,
} }
impl Uniforms { impl Uniforms {
@ -105,16 +107,16 @@ impl Instance {
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct InstanceRaw { struct InstanceRaw {
model: cgmath::Matrix4<f32>, model: Mat4,
} }
unsafe impl bytemuck::Pod for InstanceRaw {} unsafe impl bytemuck::Pod for InstanceRaw {}
unsafe impl bytemuck::Zeroable for InstanceRaw {} unsafe impl bytemuck::Zeroable for InstanceRaw {}
struct State { struct State {
instance: wgpu::Instance, _instance: wgpu::Instance,
surface: wgpu::Surface, surface: wgpu::Surface,
adapter: wgpu::Adapter, _adapter: wgpu::Adapter,
device: wgpu::Device, device: wgpu::Device,
queue: wgpu::Queue, queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor, sc_desc: wgpu::SwapChainDescriptor,
@ -131,7 +133,7 @@ struct State {
obj_model: Model, obj_model: Model,
instances: Vec<Instance>, instances: Vec<Instance>,
instance_buffer: wgpu::Buffer, _instance_buffer: wgpu::Buffer,
light: light::Light, light: light::Light,
light_buffer: wgpu::Buffer, light_buffer: wgpu::Buffer,
@ -393,9 +395,9 @@ impl State {
texture::Texture::create_depth_texture(&device, &sc_desc, "depth_texture"); texture::Texture::create_depth_texture(&device, &sc_desc, "depth_texture");
Self { Self {
instance, _instance: instance,
surface, surface,
adapter, _adapter: adapter,
device, device,
queue, queue,
sc_desc, sc_desc,
@ -412,7 +414,7 @@ impl State {
light_bind_group, light_bind_group,
light_render_pipeline, light_render_pipeline,
instances, instances,
instance_buffer, _instance_buffer: instance_buffer,
render_pipeline, render_pipeline,
size, size,
} }

View file

@ -10,7 +10,7 @@ pub struct Texture {
} }
impl Texture { impl Texture {
pub fn from_bytes( pub fn _from_bytes(
device: &wgpu::Device, device: &wgpu::Device,
queue: &wgpu::Queue, queue: &wgpu::Queue,
bytes: &[u8], bytes: &[u8],