diff options
-rw-r--r-- | CHANGELOG.txt | 5 | ||||
-rw-r--r-- | source/dw/app.rs | 1 | ||||
-rw-r--r-- | source/dw/app/ini.rs | 10 | ||||
-rw-r--r-- | source/dw/app/inigfx.rs | 16 | ||||
-rw-r--r-- | source/dw/app/lop.rs | 21 |
5 files changed, 40 insertions, 13 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c40da8c..c767f78 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,3 +3,8 @@ * Add gitignore; * Add cargo configuration file; * Add changelog; + +* Put main loop in its own method; +* Add copyright notice to start print; +* Fix spaces; +* Add goodbye message; diff --git a/source/dw/app.rs b/source/dw/app.rs index dea50da..caba0c1 100644 --- a/source/dw/app.rs +++ b/source/dw/app.rs @@ -16,3 +16,4 @@ pub struct App { pub mod ini; pub mod inigfx; +pub mod lop; diff --git a/source/dw/app/ini.rs b/source/dw/app/ini.rs index d064259..5d168eb 100644 --- a/source/dw/app/ini.rs +++ b/source/dw/app/ini.rs @@ -7,14 +7,14 @@ extern crate glfw; impl App { pub fn ini(&mut self) -> i8 { - eprintln!("DeltaWorld {}.{}.{}",VER.maj,VER.min,VER.pat); + println!("\x1B[0m\x1B[1mDeltaWorld\x1B[0m {}.{}.{} \u{2014} Copyright 2023 \x1B[0m\x1B[1mGabriel Jensen\x1B[0m.\n",VER.maj,VER.min,VER.pat); let mut gfx = self.inigfx(); - while !gfx.win.should_close() { - gfx.glfw.poll_events(); - } + let cod = self.lop(&mut gfx); - return 0x45; + println!("goodbye"); + eprintln!("exiting with code {}",cod); + return cod; } } diff --git a/source/dw/app/inigfx.rs b/source/dw/app/inigfx.rs index 00c76da..b037757 100644 --- a/source/dw/app/inigfx.rs +++ b/source/dw/app/inigfx.rs @@ -12,25 +12,25 @@ use std::ffi::c_void; impl App { pub fn inigfx(&mut self) -> Gfx { eprintln!("initialising glfw"); - let mut glfw = glfw:: init(glfw:: FAIL_ON_ERRORS).unwrap(); + let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap(); eprintln!("creating window"); - glfw.window_hint(glfw:: WindowHint:: ContextVersion(0x3,0x2)); - glfw.window_hint(glfw:: WindowHint:: OpenGlProfile(glfw:: OpenGlProfileHint:: Core)); - glfw.window_hint(glfw:: WindowHint:: Samples(Some(0x8))); + glfw.window_hint(glfw::WindowHint::ContextVersion(0x3,0x2)); + glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core)); + glfw.window_hint(glfw::WindowHint::Samples(Some(0x8))); - let (mut win,evt) = glfw.create_window(0x400,0x300,"dw",glfw:: WindowMode:: Windowed).expect("unable to create window"); + let (mut win,evt) = glfw.create_window(0x400,0x300,"dw",glfw::WindowMode::Windowed).expect("unable to create window"); win.set_key_polling(true); win.make_current(); eprintln!("initialising opengl"); - gl:: load_with(|nam| glfw.get_proc_address_raw(nam) as *const c_void); + gl::load_with(|nam| glfw.get_proc_address_raw(nam) as *const c_void); return Gfx { glfw: glfw, - win: win, - evt: evt, + win: win, + evt: evt, }; } } diff --git a/source/dw/app/lop.rs b/source/dw/app/lop.rs new file mode 100644 index 0000000..af3e81c --- /dev/null +++ b/source/dw/app/lop.rs @@ -0,0 +1,21 @@ +// Copyright 2023 Gabriel Jensen. + +use crate::dw::app::App; +use crate::dw::app::Gfx; + +//extern crate gl; +extern crate glfw; + +use glfw::{Context}; + +impl App { + pub fn lop(&mut self,gfx: &mut Gfx) -> i8 { + eprintln!("entering main loop"); + + while !gfx.win.should_close() { + gfx.glfw.poll_events(); + } + + return -0x45; + } +} |