diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/dw.rs | 16 | ||||
-rw-r--r-- | source/dw/app.rs | 1 | ||||
-rw-r--r-- | source/dw/app/end.rs | 19 | ||||
-rw-r--r-- | source/dw/app/ini.rs | 2 | ||||
-rw-r--r-- | source/dw/app/inigfx.rs | 2 | ||||
-rw-r--r-- | source/dw/app/lop.rs | 11 | ||||
-rw-r--r-- | source/dw/app/shader/main.frag.glsl | 2 | ||||
-rw-r--r-- | source/dw/app/shader/main.vert.glsl | 2 |
8 files changed, 47 insertions, 8 deletions
diff --git a/source/dw.rs b/source/dw.rs index b09c2e6..70ac3f8 100644 --- a/source/dw.rs +++ b/source/dw.rs @@ -12,12 +12,26 @@ pub const VER: VerTyp = VerTyp { pat: 0x0, }; +#[allow(dead_code)] +pub struct Pos<T> { + x: T, + y: T, + z: T, +} + +#[allow(dead_code)] +pub struct Cub { + //pos +} + pub const fn datpth() -> &'static str { if cfg!(unix) { //return "/usr/share/local/deltaworld"; return "/home/delta/Repositories/deltaworld" } - return ""; + else { + panic!("data directory not found"); + } } pub mod app; diff --git a/source/dw/app.rs b/source/dw/app.rs index ffd44fb..3fbc61f 100644 --- a/source/dw/app.rs +++ b/source/dw/app.rs @@ -20,6 +20,7 @@ pub struct App { static mut GOTINT: AtomicBool = AtomicBool::new(false); pub mod getshdprg; +pub mod end; pub mod ini; pub mod inigfx; pub mod inisig; diff --git a/source/dw/app/end.rs b/source/dw/app/end.rs new file mode 100644 index 0000000..1ada74b --- /dev/null +++ b/source/dw/app/end.rs @@ -0,0 +1,19 @@ +// Copyright 2023 Gabriel Jensen. + +use crate::dw::app::{App, Gfx}; + +extern crate gl; + +use gl::{DeleteProgram}; + +impl App { + pub fn end(&mut self,gfx: &mut Gfx) { + eprintln!("ending"); + + unsafe { + DeleteProgram(gfx.shdprg); + } + + // GLFW is automatically "destroyed". + } +} diff --git a/source/dw/app/ini.rs b/source/dw/app/ini.rs index f498538..5f4c535 100644 --- a/source/dw/app/ini.rs +++ b/source/dw/app/ini.rs @@ -17,6 +17,8 @@ impl App { let cod = self.lop(&mut gfx); + self.end(&mut gfx); + println!("goodbye"); eprintln!("exiting with code {}", cod); return cod; diff --git a/source/dw/app/inigfx.rs b/source/dw/app/inigfx.rs index ec8e0a0..d137c5a 100644 --- a/source/dw/app/inigfx.rs +++ b/source/dw/app/inigfx.rs @@ -22,9 +22,9 @@ impl App { let (mut win, evt) = glfw.create_window(0x400, 0x300, format!("DeltaWorld {}.{}.{}", VER.maj, VER.min, VER.pat).as_str(), glfw::WindowMode::Windowed).expect("unable to create window"); win.set_key_polling(true); - win.make_current(); eprintln!("initialising opengl"); + win.make_current(); load_with(|nam| glfw.get_proc_address_raw(nam) as *const c_void); glfw.set_swap_interval(SwapInterval::Sync(0x1)); diff --git a/source/dw/app/lop.rs b/source/dw/app/lop.rs index d18415f..0a8f36b 100644 --- a/source/dw/app/lop.rs +++ b/source/dw/app/lop.rs @@ -6,7 +6,7 @@ use crate::dw::app::Gfx; extern crate gl; extern crate glfw; -use gl::{ARRAY_BUFFER, BindBuffer, BufferData, BindVertexArray, BufferSubData, Clear, ClearColor, COLOR_BUFFER_BIT, DrawArrays, EnableVertexAttribArray, FALSE, FLOAT, GenBuffers, GenVertexArrays, STREAM_DRAW, TRIANGLES, UseProgram, VertexAttribPointer}; +use gl::{ARRAY_BUFFER, BindBuffer, BufferData, BindVertexArray, BufferSubData, Clear, ClearColor, COLOR_BUFFER_BIT, DrawArrays, EnableVertexAttribArray, FALSE, FLOAT, GenBuffers, GenVertexArrays, STREAM_DRAW, TRIANGLES, UseProgram, VertexAttribPointer, Viewport}; use gl::types::{GLfloat, GLsizeiptr, GLuint}; use glfw::Context; use std::ffi::c_void; @@ -19,9 +19,9 @@ impl App { eprintln!("entering main loop"); let vtx: [GLfloat; 0x9] = [ - -1.0, 1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, 0.0, 0.0, + -0.707,-0.707, -0.707, + -0.707, 0.707, -0.707, + 0.707,-0.707, -0.707, ]; let mut vao: GLuint = 0x0; @@ -51,6 +51,9 @@ impl App { gfx.glfw.poll_events(); unsafe { + let (frmwdh, frmhgh) = gfx.win.get_framebuffer_size(); + Viewport(0x0,0x0,frmwdh,frmhgh); + ClearColor(0.107, 0.690, 0.939, 1.0); Clear(COLOR_BUFFER_BIT); diff --git a/source/dw/app/shader/main.frag.glsl b/source/dw/app/shader/main.frag.glsl index b3da28d..6f14883 100644 --- a/source/dw/app/shader/main.frag.glsl +++ b/source/dw/app/shader/main.frag.glsl @@ -2,6 +2,6 @@ out vec4 col; -void main() { +void main(void) { col = vec4(0.409f, 0.805f, 0.210f, 1.0f); } diff --git a/source/dw/app/shader/main.vert.glsl b/source/dw/app/shader/main.vert.glsl index a60e9ca..16df6f0 100644 --- a/source/dw/app/shader/main.vert.glsl +++ b/source/dw/app/shader/main.vert.glsl @@ -2,6 +2,6 @@ in vec3 pos; -void main() { +void main(void) { gl_Position = vec4(pos.x, pos.y, pos.z, 1.0f); } |