diff options
Diffstat (limited to 'engine/src/opengl/util.rs')
-rw-r--r-- | engine/src/opengl/util.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/engine/src/opengl/util.rs b/engine/src/opengl/util.rs new file mode 100644 index 0000000..e60778f --- /dev/null +++ b/engine/src/opengl/util.rs @@ -0,0 +1,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; |