2020-02-16 23:32:35 +00:00
|
|
|
// Trivial wrappers around GLESv2 C functions that should be safe
|
|
|
|
|
2020-02-16 23:44:01 +00:00
|
|
|
use glam::{Mat4, Vec3, Vec4};
|
|
|
|
|
2020-02-16 23:32:35 +00:00
|
|
|
pub fn clear_color (r: f32, g: f32, b: f32, a: f32) {
|
|
|
|
unsafe {
|
2020-02-17 02:09:13 +00:00
|
|
|
gl::ClearColor (r, g, b, a);
|
2020-02-16 23:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 23:44:01 +00:00
|
|
|
|
2020-03-07 03:36:05 +00:00
|
|
|
pub fn front_face (constant: u32) {
|
|
|
|
unsafe {
|
|
|
|
gl::FrontFace (constant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn blend_func (src: u32, dst: u32) {
|
|
|
|
unsafe {
|
|
|
|
gl::BlendFunc (src, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 23:49:38 +00:00
|
|
|
pub fn enable_vertex_attrib_array (id: Option <u32>) {
|
|
|
|
if let Some (id) = id {
|
|
|
|
// Are safety checks really needed here?
|
|
|
|
unsafe {
|
|
|
|
gl::EnableVertexAttribArray (id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 23:48:26 +00:00
|
|
|
pub fn uniform_1i (uni: i32, x: i32) {
|
|
|
|
unsafe {
|
|
|
|
gl::Uniform1i (uni, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-07 03:36:05 +00:00
|
|
|
pub fn uniform_1f (uni: i32, x: f32) {
|
|
|
|
unsafe {
|
|
|
|
gl::Uniform1f (uni, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 23:44:01 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2020-02-17 00:32:52 +00:00
|
|
|
|
2020-03-08 19:32:02 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 03:06:52 +00:00
|
|
|
// More abstract things below here
|
2020-02-17 00:32:52 +00:00
|
|
|
|
|
|
|
|