diff --git a/src/bin/pumpkin.rs b/src/bin/pumpkin.rs index 44713b9..a57d8f9 100644 --- a/src/bin/pumpkin.rs +++ b/src/bin/pumpkin.rs @@ -241,14 +241,12 @@ fn main () { const FALSE_U8: u8 = 0; - unsafe { - enable_vertex_attrib_array (attrs ["pos"]); - enable_vertex_attrib_array (attrs ["uv"]); - enable_vertex_attrib_array (attrs ["normal"]); - - gl::Enable (gl::DEPTH_TEST); - gl::Enable (gl::TEXTURE); - } + enable_vertex_attrib_array (attrs ["pos"]); + enable_vertex_attrib_array (attrs ["uv"]); + enable_vertex_attrib_array (attrs ["normal"]); + + glezz::enable (gl::DEPTH_TEST); + glezz::enable (gl::TEXTURE); let mut time_step = TimeStep::new (60, 1000); let mut state = WorldState::new (); @@ -307,11 +305,11 @@ fn main () { let orange = orange * orange; let green = green * green; + glezz::clear_color (1.0f32, 1.0f32, 1.0f32, 1.0f32); + glezz::clear (gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT); + glezz::disable (gl::CULL_FACE); + unsafe { - gl::ClearColor (1.0f32, 1.0f32, 1.0f32, 1.0f32); - gl::Clear (gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT); - gl::Disable (gl::CULL_FACE); - gl::Uniform3fv (unis ["min_bright"], 1, &black as *const Vec3 as *const f32); gl::Uniform3fv (unis ["min_albedo"], 1, &white as *const Vec3 as *const f32); diff --git a/src/glezz.rs b/src/glezz.rs new file mode 100644 index 0000000..9e1d87a --- /dev/null +++ b/src/glezz.rs @@ -0,0 +1,25 @@ +// Trivial wrappers around GLESv2 C functions that should be safe + +pub fn clear_color (r: f32, g: f32, b: f32, a: f32) { + unsafe { + gl::ClearColor (1.0f32, 1.0f32, 1.0f32, 1.0f32); + } +} + +pub fn clear (flags: u32) { + unsafe { + gl::Clear (flags); + } +} + +pub fn disable (constant: u32) { + unsafe { + gl::Disable (constant); + } +} + +pub fn enable (constant: u32) { + unsafe { + gl::Enable (constant); + } +} diff --git a/src/lib.rs b/src/lib.rs index a28090c..e66193d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod file; +pub mod glezz; pub mod iqm; pub mod shader; pub mod texture;