From be968adb89335619998e7556c1c96ae111e31045 Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sun, 21 Aug 2022 21:09:19 +0200 Subject: [PATCH] Removed warnings --- src/io.rs | 1 + src/lib.rs | 9 +++++---- src/main.rs | 8 +------- src/renderer.rs | 6 +++--- src/sprite.rs | 13 ++++--------- src/texture.rs | 1 - src/utils.rs | 18 ------------------ 7 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/io.rs b/src/io.rs index fb5d940..f0f592a 100644 --- a/src/io.rs +++ b/src/io.rs @@ -12,6 +12,7 @@ bitflags! { } //--Scroll struct----------------------------------------------------------------------------------- +#[allow(dead_code)] pub struct Scroll { x: f32, y: f32, diff --git a/src/lib.rs b/src/lib.rs index 9332b46..fac16f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,9 +15,10 @@ mod renderer; use utils::Size; -pub fn run_canvas>(title: &'static str, - size: Size, mut app: A) - -> ! +pub fn run_canvas(title: &'static str, size: Size, _: A) -> ! +where + S: 'static + Sized, + A: 'static + Application, { use winit::{ event_loop::EventLoop, @@ -61,7 +62,7 @@ pub fn run_canvas>(title: &'stat WindowEvent::Resized (size) => { canvas.set_size(size.into()); }, - WindowEvent::ScaleFactorChanged {new_inner_size, ..} => { + WindowEvent::ScaleFactorChanged {/*new_inner_size, */..} => { // new_inner_size is &&mut so we have to dereference it twice // canvas does not support resize, do nothing //canvas.set_size((*new_inner_size).into()); diff --git a/src/main.rs b/src/main.rs index 7ed6dfc..c81b026 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,6 @@ use canvas::{ }; use std::{ - rc::Rc, - cell::RefCell, time::Instant, }; @@ -57,8 +55,7 @@ impl Application for ExampleApp { fn init(canvas: &mut Canvas) -> Result { use canvas::{ - utils::{Position, Size}, - sprite::Sprite, + utils::{Size}, }; //// 20 x 20 sprite of a picture @@ -88,10 +85,7 @@ impl Application for ExampleApp { fn tick(state: &mut ExampleState, canvas: &mut Canvas) -> Result<(), &'static str> { use canvas::{ - io::Key, sprite::Sprite, - utils::{Position, Size, Color, Pixel}, - shape::{Shape, Rectangle}, }; let now = Instant::now(); diff --git a/src/renderer.rs b/src/renderer.rs index 5e10146..fdfc1a0 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -3,11 +3,9 @@ use log::{debug, error, info, trace, warn}; use raw_window_handle::HasRawWindowHandle; use wgpu; -use wgpu_hal; -use cgmath::Matrix3; use crate::{ - sprite::{Sprite, ModelMatrix, MATRIX_SIZE}, + sprite::{Sprite, MATRIX_SIZE}, texture::{GpuTexture}, utils::{Pixel, Size}, }; @@ -32,7 +30,9 @@ pub struct WgpuRenderer { texture_bind_group_layout: wgpu::BindGroupLayout, texture_render_pipeline: wgpu::RenderPipeline, + #[allow(dead_code)] shape_render_pipeline: wgpu::RenderPipeline, + #[allow(dead_code)] quad_mesh: GpuMesh, //TODO temporary, to be moved to shapes.rs } diff --git a/src/sprite.rs b/src/sprite.rs index 3e09108..787b956 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -5,7 +5,7 @@ use crate::{ renderer::{Mesh, GpuMesh, RenderData, TextureVertex, GpuUniform}, shape::Shape, texture::Texture, - utils::{Pixel, Position, Size, NormalizedSize}, + utils::{Pixel, Position, Size}, }; use cgmath::{ @@ -15,12 +15,6 @@ use cgmath::{ Matrix4, }; -use std::{ - rc::Rc, - cell::RefCell, - slice::{Iter, IterMut}, -}; - //--Sprite trait------------------------------------------------------------------------------------ pub trait Sprite { @@ -49,7 +43,6 @@ impl ModelMatrix { uniform: GpuUniform) -> Self { - use cgmath::SquareMatrix; Self { position: pos, @@ -81,7 +74,7 @@ impl ModelMatrix { } pub fn get_uniform(&mut self) -> &mut GpuUniform { - use cgmath::{Basis3, Rotation3, SquareMatrix}; + use cgmath::{Basis3, Rotation3}; if self.is_synced == false { @@ -238,6 +231,7 @@ impl Sprite for TextureSprite { } //--TextSprite struct------------------------------------------------------------------------------- +#[allow(dead_code)] pub struct TextSprite { matrix: Matrix4, size: Size, @@ -279,6 +273,7 @@ impl Sprite for TextSprite { } //--ShapeSprite struct------------------------------------------------------------------------------- +#[allow(dead_code)] pub struct ShapeSprite { matrix: Matrix4, size: Size, diff --git a/src/texture.rs b/src/texture.rs index 600dfb2..be2fcc7 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -4,7 +4,6 @@ use log::{debug, error, info, trace, warn}; use crate::utils::{Pixel, Position, Size}; use std::{ - slice::{Iter, IterMut}, rc::Rc, cell::RefCell, }; diff --git a/src/utils.rs b/src/utils.rs index ecda784..4e5959e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -79,24 +79,6 @@ impl From> for Size { } } -//--NormalizedSize struct--------------------------------------------------------------------------- -#[derive(Copy, Clone)] -pub struct NormalizedSize { - pub w: f32, - pub h: f32, -} - -impl NormalizedSize { - - pub fn from_size(size: Size, surface_size: Size) -> Self { - - Self { - w: size.w as f32 / surface_size.w as f32, - h: size.h as f32 / surface_size.h as f32, - } - } -} - //--Pixel struct------------------------------------------------------------------------------------ #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[repr(C)]