diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | CHANGELOG.txt | 5 | ||||
-rw-r--r-- | Cargo.toml | 17 | ||||
-rw-r--r-- | source/dw.rs | 15 | ||||
-rw-r--r-- | source/dw/app.rs | 18 | ||||
-rw-r--r-- | source/dw/app/ini.rs | 20 | ||||
-rw-r--r-- | source/dw/app/inigfx.rs | 36 | ||||
-rw-r--r-- | source/ini.rs | 13 |
8 files changed, 126 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..c40da8c --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,5 @@ +# 0.0.0 + +* Add gitignore; +* Add cargo configuration file; +* Add changelog; diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..dafa6e5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "deltaworld" +version = "0.0.0" +edition = "2021" + +[[bin]] +name = "dw" +path = "source/ini.rs" + +[profile.release] +lto = true + +[dependencies.gl] +version = "*" + +[dependencies.glfw] +version = "*" diff --git a/source/dw.rs b/source/dw.rs new file mode 100644 index 0000000..976f049 --- /dev/null +++ b/source/dw.rs @@ -0,0 +1,15 @@ +// Copyright 2023 Gabriel Jensen. + +pub struct VerTyp { + pub maj: u64, + pub min: u64, + pub pat: u64, +} + +pub const VER: VerTyp = VerTyp { + maj: 0x0, + min: 0x0, + pat: 0x0, +}; + +pub mod app; diff --git a/source/dw/app.rs b/source/dw/app.rs new file mode 100644 index 0000000..dea50da --- /dev/null +++ b/source/dw/app.rs @@ -0,0 +1,18 @@ +// Copyright 2023 Gabriel Jensen. + +extern crate glfw; + +use glfw::{Glfw,Window,WindowEvent}; +use std::sync::mpsc::Receiver; + +pub struct Gfx { + evt: Receiver<(f64,WindowEvent)>, + glfw: Glfw, + win: Window, +} + +pub struct App { +} + +pub mod ini; +pub mod inigfx; diff --git a/source/dw/app/ini.rs b/source/dw/app/ini.rs new file mode 100644 index 0000000..d064259 --- /dev/null +++ b/source/dw/app/ini.rs @@ -0,0 +1,20 @@ +// Copyright 2023 Gabriel Jensen. + +use crate::dw::app::App; +use crate::dw::VER; + +extern crate glfw; + +impl App { + pub fn ini(&mut self) -> i8 { + eprintln!("DeltaWorld {}.{}.{}",VER.maj,VER.min,VER.pat); + + let mut gfx = self.inigfx(); + + while !gfx.win.should_close() { + gfx.glfw.poll_events(); + } + + return 0x45; + } +} diff --git a/source/dw/app/inigfx.rs b/source/dw/app/inigfx.rs new file mode 100644 index 0000000..00c76da --- /dev/null +++ b/source/dw/app/inigfx.rs @@ -0,0 +1,36 @@ +// Copyright 2023 Gabriel Jensen. + +use crate::dw::app::App; +use crate::dw::app::Gfx; + +extern crate gl; +extern crate glfw; + +use glfw::{Context}; +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(); + + 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))); + + + 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); + + return Gfx { + glfw: glfw, + win: win, + evt: evt, + }; + } +} diff --git a/source/ini.rs b/source/ini.rs new file mode 100644 index 0000000..aa0802c --- /dev/null +++ b/source/ini.rs @@ -0,0 +1,13 @@ +// Copyright 2023 Gabriel Jensen. + +mod dw; + +use crate::dw::app::App; + +use std::process::exit; + +fn main() { + let mut app = App {}; + + exit(app.ini() as i32); +} |