moved to rust style file tree

This commit is contained in:
2019-09-21 23:59:43 -07:00
parent fa2c9397bf
commit 34c23eebc0
21 changed files with 146 additions and 187 deletions

View File

@@ -3,6 +3,10 @@ use std::sync::Arc;
use std::ffi::CStr;
use std::path::PathBuf;
pub mod timer;
pub mod vertex_2d;
pub mod vertex_3d;
pub fn load_raw(filename: String) -> (Vec<u8>, (u32,u32)) {
let project_root =

30
src/util/timer.rs Normal file
View File

@@ -0,0 +1,30 @@
use simple_stopwatch::Stopwatch;
pub struct Timer {
stopwatch: Stopwatch,
lap: f32
}
impl Timer {
pub fn new() -> Timer {
let started = Stopwatch::start_new();
let mut time_now = started.ms();
Timer {
stopwatch: started,
lap: time_now
}
}
pub fn elap_time(&mut self) -> f32 {
self.stopwatch.ms() / 1000.0
}
pub fn frame_time(&mut self) -> f32 {
let now = self.stopwatch.ms();
let elapsed = now - self.lap;
self.lap = now;
return elapsed
}
}

10
src/util/vertex_2d.rs Normal file
View File

@@ -0,0 +1,10 @@
/// Generic vertex 2d with vertex position, texture position and a 32bit color
#[derive(Default, Debug, Clone, Copy)]
pub struct Vertex2D {
pub v_position: [f32; 2],
pub color : [f32; 4],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(Vertex2D, v_position, color, ti_position);

11
src/util/vertex_3d.rs Normal file
View File

@@ -0,0 +1,11 @@
/// Generic vertex 3d with vertex position, texture position and a 32bit color
#[derive(Default, Debug, Clone, Copy)]
pub struct Vertex3D {
pub v_position: [f32; 3],
pub color : [f32; 4],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(Vertex3D, v_position, color, ti_position);