diff options
Diffstat (limited to 'source/dw/app')
-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 |
6 files changed, 31 insertions, 7 deletions
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); } |