♻️ Safened all GL calls except those that actually do access arbitrary memory.

main
_ 2020-02-16 23:49:38 +00:00
parent c6f71abbca
commit d45b95961e
2 changed files with 12 additions and 12 deletions

View File

@ -82,15 +82,6 @@ void main (void) {
} }
"; ";
fn enable_vertex_attrib_array (id: Option <u32>) {
if let Some (id) = id {
// Are safety checks really needed here?
unsafe {
gl::EnableVertexAttribArray (id);
}
}
}
unsafe fn vertex_attrib_pointer (id: Option <u32>, num_coords: i32, slice: &[u8]) { unsafe fn vertex_attrib_pointer (id: Option <u32>, num_coords: i32, slice: &[u8]) {
const FALSE_U8: u8 = 0; const FALSE_U8: u8 = 0;
const FLOAT_SIZE: i32 = 4; const FLOAT_SIZE: i32 = 4;
@ -241,9 +232,9 @@ fn main () {
const FALSE_U8: u8 = 0; const FALSE_U8: u8 = 0;
enable_vertex_attrib_array (attrs ["pos"]); glezz::enable_vertex_attrib_array (attrs ["pos"]);
enable_vertex_attrib_array (attrs ["uv"]); glezz::enable_vertex_attrib_array (attrs ["uv"]);
enable_vertex_attrib_array (attrs ["normal"]); glezz::enable_vertex_attrib_array (attrs ["normal"]);
glezz::enable (gl::DEPTH_TEST); glezz::enable (gl::DEPTH_TEST);
glezz::enable (gl::TEXTURE); glezz::enable (gl::TEXTURE);

View File

@ -26,6 +26,15 @@ pub fn enable (constant: u32) {
} }
} }
pub fn enable_vertex_attrib_array (id: Option <u32>) {
if let Some (id) = id {
// Are safety checks really needed here?
unsafe {
gl::EnableVertexAttribArray (id);
}
}
}
pub fn uniform_1i (uni: i32, x: i32) { pub fn uniform_1i (uni: i32, x: i32) {
unsafe { unsafe {
gl::Uniform1i (uni, x); gl::Uniform1i (uni, x);