grafix_toolbox/kit/opengl/control/
consts.rs1use crate::lib::*;
2
3macro_rules! CONST {
4 ($n: ident, $t: ty) => {
5 pub fn $n() -> $t {
6 static mut DONE: bool = false;
7 static mut RES: $t = 0 as $t;
8 unsafe {
9 if DONE == true {
10 } else {
11 DONE = true;
12 RES = <$t>::get(gl::$n)
13 }
14 }
15 unsafe { RES }
16 }
17 };
18}
19
20pub trait Get {
21 fn get(_: GLenum) -> Self;
22}
23macro_rules! impl_get {
24 ($t: ty, $f: ident) => {
25 impl Get for $t {
26 fn get(p: GLenum) -> Self {
27 let mut r = Def();
28 GL!(gl::$f(p, &mut r));
29 r
30 }
31 }
32 };
33}
34impl_get!(GLbool, GetBooleanv);
35impl_get!(i32, GetIntegerv);
36impl_get!(f32, GetFloatv);
37impl_get!(f64, GetDoublev);