// Trivial wrappers around GLESv2 C functions that should be safe use glam::{Mat4, Vec3, Vec4}; pub fn clear_color (r: f32, g: f32, b: f32, a: f32) { unsafe { gl::ClearColor (r, g, b, a); } } 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); } } pub fn front_face (constant: u32) { unsafe { gl::FrontFace (constant); } } pub fn blend_func (src: u32, dst: u32) { unsafe { gl::BlendFunc (src, dst); } } 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); } } pub fn uniform_1f (uni: i32, x: f32) { unsafe { gl::Uniform1f (uni, x); } } pub fn uniform_3fv (uni: i32, v: &Vec3) { unsafe { gl::Uniform3fv (uni, 1, v as *const Vec3 as *const f32); } } pub fn uniform_4fv (uni: i32, v: &Vec4) { unsafe { gl::Uniform4fv (uni, 1, v as *const Vec4 as *const f32); } } pub fn uniform_matrix_4fv (uni: i32, m: &Mat4) { const FALSE_U8: u8 = 0; unsafe { gl::UniformMatrix4fv (uni, 1, FALSE_U8, m as *const Mat4 as *const f32); } } pub fn color_mask (r: u8, g: u8, b: u8, a: u8) { unsafe { gl::ColorMask (r, g, b, a); } } pub fn depth_mask (v: u8) { unsafe { gl::DepthMask (v); } } pub fn stencil_mask (v: u32) { unsafe { gl::StencilMask (v); } } pub fn depth_func (v: u32) { unsafe { gl::DepthFunc (v); } } // More abstract things below here