Removed warnings
This commit is contained in:
parent
d3bc7ecc7f
commit
be968adb89
@ -12,6 +12,7 @@ bitflags! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--Scroll struct-----------------------------------------------------------------------------------
|
//--Scroll struct-----------------------------------------------------------------------------------
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct Scroll {
|
pub struct Scroll {
|
||||||
x: f32,
|
x: f32,
|
||||||
y: f32,
|
y: f32,
|
||||||
|
|||||||
@ -15,9 +15,10 @@ mod renderer;
|
|||||||
|
|
||||||
use utils::Size;
|
use utils::Size;
|
||||||
|
|
||||||
pub fn run_canvas<S: 'static + Sized, A: 'static + Application<S>>(title: &'static str,
|
pub fn run_canvas<S, A>(title: &'static str, size: Size, _: A) -> !
|
||||||
size: Size, mut app: A)
|
where
|
||||||
-> !
|
S: 'static + Sized,
|
||||||
|
A: 'static + Application<S>,
|
||||||
{
|
{
|
||||||
use winit::{
|
use winit::{
|
||||||
event_loop::EventLoop,
|
event_loop::EventLoop,
|
||||||
@ -61,7 +62,7 @@ pub fn run_canvas<S: 'static + Sized, A: 'static + Application<S>>(title: &'stat
|
|||||||
WindowEvent::Resized (size) => {
|
WindowEvent::Resized (size) => {
|
||||||
canvas.set_size(size.into());
|
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
|
// new_inner_size is &&mut so we have to dereference it twice
|
||||||
// canvas does not support resize, do nothing
|
// canvas does not support resize, do nothing
|
||||||
//canvas.set_size((*new_inner_size).into());
|
//canvas.set_size((*new_inner_size).into());
|
||||||
|
|||||||
@ -10,8 +10,6 @@ use canvas::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
rc::Rc,
|
|
||||||
cell::RefCell,
|
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,8 +55,7 @@ impl Application<ExampleState> for ExampleApp {
|
|||||||
|
|
||||||
fn init(canvas: &mut Canvas) -> Result<ExampleState, &'static str> {
|
fn init(canvas: &mut Canvas) -> Result<ExampleState, &'static str> {
|
||||||
use canvas::{
|
use canvas::{
|
||||||
utils::{Position, Size},
|
utils::{Size},
|
||||||
sprite::Sprite,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//// 20 x 20 sprite of a picture
|
//// 20 x 20 sprite of a picture
|
||||||
@ -88,10 +85,7 @@ impl Application<ExampleState> for ExampleApp {
|
|||||||
|
|
||||||
fn tick(state: &mut ExampleState, canvas: &mut Canvas) -> Result<(), &'static str> {
|
fn tick(state: &mut ExampleState, canvas: &mut Canvas) -> Result<(), &'static str> {
|
||||||
use canvas::{
|
use canvas::{
|
||||||
io::Key,
|
|
||||||
sprite::Sprite,
|
sprite::Sprite,
|
||||||
utils::{Position, Size, Color, Pixel},
|
|
||||||
shape::{Shape, Rectangle},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|||||||
@ -3,11 +3,9 @@ use log::{debug, error, info, trace, warn};
|
|||||||
|
|
||||||
use raw_window_handle::HasRawWindowHandle;
|
use raw_window_handle::HasRawWindowHandle;
|
||||||
use wgpu;
|
use wgpu;
|
||||||
use wgpu_hal;
|
|
||||||
use cgmath::Matrix3;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
sprite::{Sprite, ModelMatrix, MATRIX_SIZE},
|
sprite::{Sprite, MATRIX_SIZE},
|
||||||
texture::{GpuTexture},
|
texture::{GpuTexture},
|
||||||
utils::{Pixel, Size},
|
utils::{Pixel, Size},
|
||||||
};
|
};
|
||||||
@ -32,7 +30,9 @@ pub struct WgpuRenderer {
|
|||||||
texture_bind_group_layout: wgpu::BindGroupLayout,
|
texture_bind_group_layout: wgpu::BindGroupLayout,
|
||||||
texture_render_pipeline: wgpu::RenderPipeline,
|
texture_render_pipeline: wgpu::RenderPipeline,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
shape_render_pipeline: wgpu::RenderPipeline,
|
shape_render_pipeline: wgpu::RenderPipeline,
|
||||||
|
#[allow(dead_code)]
|
||||||
quad_mesh: GpuMesh<ColorVertex, 4, 6>, //TODO temporary, to be moved to shapes.rs
|
quad_mesh: GpuMesh<ColorVertex, 4, 6>, //TODO temporary, to be moved to shapes.rs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use crate::{
|
|||||||
renderer::{Mesh, GpuMesh, RenderData, TextureVertex, GpuUniform},
|
renderer::{Mesh, GpuMesh, RenderData, TextureVertex, GpuUniform},
|
||||||
shape::Shape,
|
shape::Shape,
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
utils::{Pixel, Position, Size, NormalizedSize},
|
utils::{Pixel, Position, Size},
|
||||||
};
|
};
|
||||||
|
|
||||||
use cgmath::{
|
use cgmath::{
|
||||||
@ -15,12 +15,6 @@ use cgmath::{
|
|||||||
Matrix4,
|
Matrix4,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{
|
|
||||||
rc::Rc,
|
|
||||||
cell::RefCell,
|
|
||||||
slice::{Iter, IterMut},
|
|
||||||
};
|
|
||||||
|
|
||||||
//--Sprite trait------------------------------------------------------------------------------------
|
//--Sprite trait------------------------------------------------------------------------------------
|
||||||
pub trait Sprite {
|
pub trait Sprite {
|
||||||
|
|
||||||
@ -49,7 +43,6 @@ impl ModelMatrix {
|
|||||||
uniform: GpuUniform<MATRIX_SIZE>)
|
uniform: GpuUniform<MATRIX_SIZE>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
use cgmath::SquareMatrix;
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
position: pos,
|
position: pos,
|
||||||
@ -81,7 +74,7 @@ impl ModelMatrix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_uniform(&mut self) -> &mut GpuUniform<MATRIX_SIZE> {
|
pub fn get_uniform(&mut self) -> &mut GpuUniform<MATRIX_SIZE> {
|
||||||
use cgmath::{Basis3, Rotation3, SquareMatrix};
|
use cgmath::{Basis3, Rotation3};
|
||||||
|
|
||||||
if self.is_synced == false {
|
if self.is_synced == false {
|
||||||
|
|
||||||
@ -238,6 +231,7 @@ impl Sprite for TextureSprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--TextSprite struct-------------------------------------------------------------------------------
|
//--TextSprite struct-------------------------------------------------------------------------------
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct TextSprite {
|
pub struct TextSprite {
|
||||||
matrix: Matrix4<f32>,
|
matrix: Matrix4<f32>,
|
||||||
size: Size,
|
size: Size,
|
||||||
@ -279,6 +273,7 @@ impl Sprite for TextSprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--ShapeSprite struct-------------------------------------------------------------------------------
|
//--ShapeSprite struct-------------------------------------------------------------------------------
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct ShapeSprite {
|
pub struct ShapeSprite {
|
||||||
matrix: Matrix4<f32>,
|
matrix: Matrix4<f32>,
|
||||||
size: Size,
|
size: Size,
|
||||||
|
|||||||
@ -4,7 +4,6 @@ use log::{debug, error, info, trace, warn};
|
|||||||
use crate::utils::{Pixel, Position, Size};
|
use crate::utils::{Pixel, Position, Size};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
slice::{Iter, IterMut},
|
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
};
|
};
|
||||||
|
|||||||
18
src/utils.rs
18
src/utils.rs
@ -79,24 +79,6 @@ impl From<winit::dpi::PhysicalSize<u32>> 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------------------------------------------------------------------------------------
|
//--Pixel struct------------------------------------------------------------------------------------
|
||||||
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user