2021-32-bit-holiday-jam/src/glezz.rs

85 lines
1.3 KiB
Rust
Raw Normal View History

// Trivial wrappers around GLESv2 C functions that should be safe
2020-02-16 23:44:01 +00:00
use glam::{Mat4, Vec3, Vec4};
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);
}
}
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);
}
}
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);
}
}
// More abstract things below here