From d45b95961ecfb0bb19990091546b4a94f1d5eb57 Mon Sep 17 00:00:00 2001 From: _ <> Date: Sun, 16 Feb 2020 23:49:38 +0000 Subject: [PATCH] :recycle: Safened all GL calls except those that actually do access arbitrary memory. --- src/bin/pumpkin.rs | 15 +++------------ src/glezz.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bin/pumpkin.rs b/src/bin/pumpkin.rs index 0928d7d..9eaef30 100644 --- a/src/bin/pumpkin.rs +++ b/src/bin/pumpkin.rs @@ -82,15 +82,6 @@ void main (void) { } "; -fn enable_vertex_attrib_array (id: Option ) { - if let Some (id) = id { - // Are safety checks really needed here? - unsafe { - gl::EnableVertexAttribArray (id); - } - } -} - unsafe fn vertex_attrib_pointer (id: Option , num_coords: i32, slice: &[u8]) { const FALSE_U8: u8 = 0; const FLOAT_SIZE: i32 = 4; @@ -241,9 +232,9 @@ fn main () { const FALSE_U8: u8 = 0; - enable_vertex_attrib_array (attrs ["pos"]); - enable_vertex_attrib_array (attrs ["uv"]); - enable_vertex_attrib_array (attrs ["normal"]); + glezz::enable_vertex_attrib_array (attrs ["pos"]); + glezz::enable_vertex_attrib_array (attrs ["uv"]); + glezz::enable_vertex_attrib_array (attrs ["normal"]); glezz::enable (gl::DEPTH_TEST); glezz::enable (gl::TEXTURE); diff --git a/src/glezz.rs b/src/glezz.rs index 65e4754..11d6d0f 100644 --- a/src/glezz.rs +++ b/src/glezz.rs @@ -26,6 +26,15 @@ pub fn enable (constant: u32) { } } +pub fn enable_vertex_attrib_array (id: Option ) { + if let Some (id) = id { + // Are safety checks really needed here? + unsafe { + gl::EnableVertexAttribArray (id); + } + } +} + pub fn uniform_1i (uni: i32, x: i32) { unsafe { gl::Uniform1i (uni, x);