This commit is contained in:
griffi-gh 2023-01-15 16:53:02 +01:00
parent dba53e4ceb
commit fc71fda625
5 changed files with 11 additions and 11 deletions

View file

@ -24,9 +24,11 @@ pub fn run() {
log::info!("loading assets");
let assets = Assets::load_all_sync(&display);
log::info!("init camera");
let mut camera = Camera::default();
camera.position = [0., 0., -1.];
camera.direction = [0., 0., 1.];
let camera = Camera {
position: [0., 0., -1.],
direction: [0., 0., 1.],
..Default::default()
};
log::info!("game loaded");
//=======================
@ -37,7 +39,9 @@ pub fn run() {
let vertex_buffer = glium::VertexBuffer::new(&display, &shape).unwrap();
//=======================
event_loop.run(move |ev, _, control_flow| {
#[allow(clippy::single_match, clippy::collapsible_match)]
match ev {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => {
@ -56,7 +60,7 @@ pub fn run() {
target.clear_color_and_depth((0.5, 0.5, 1., 1.), 1.);
target.draw(
&vertex_buffer,
&glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList),
glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList),
&programs.chunk,
&uniform! {
model: [[0.0f32; 4]; 4],

View file

@ -6,7 +6,7 @@ fn load_png(file_path: &str, display: &glium::Display) -> SrgbTexture2d {
//Load file
let data = fs::read(file_path)
.expect(&format!("Failed to load texture: {}", file_path));
.unwrap_or_else(|_| panic!("Failed to load texture: {}", file_path));
//decode image data
let image_data = image::load(

View file

@ -14,10 +14,6 @@ pub struct Camera {
pub zfar: f32,
}
impl Camera {
pub fn new() -> Self {
Default::default()
}
pub fn view_matrix(&self) -> [[f32; 4]; 4] {
let position = self.position;
let direction = self.direction;

View file

@ -8,5 +8,5 @@ use glium::glutin::{
pub fn init_display(event_loop: &EventLoop<()>) -> Display {
let wb = WindowBuilder::new();
let cb = ContextBuilder::new().with_depth_buffer(24);
Display::new(wb, cb, &event_loop).unwrap()
Display::new(wb, cb, event_loop).unwrap()
}

View file

@ -1,4 +1,4 @@
use glium::{Display, Program, implement_vertex};
use glium::implement_vertex;
#[derive(Clone, Copy)]
pub struct Vertex {