summaryrefslogtreecommitdiff
path: root/engine/src/opengl/util.rs
blob: e60778f2c68ff76054cbcade675fa7ecf4ed7fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// May only be used when certain crate features are enabled
#![allow(unused_macros, unused_imports)]

macro_rules! gl_enum {
    (
        $visibility: vis enum $name: ident
        {$(
            $variant: ident = gl::$gl_enum: ident,
        )+}
    ) => {
        #[derive(Debug, Clone, Copy)]
        #[repr(u32)]
        $visibility enum $name
        {$(
            $variant = gl::$gl_enum,
        )+}

        impl $name {
            fn from_gl(num: gl::types::GLenum) -> Option<Self>
            {
                match num {
                    $(gl::$gl_enum => Some(Self::$variant),)+
                    _ => None
                }
            }
        }
    };
}

pub(crate) use gl_enum;