summaryrefslogtreecommitdiff
path: root/engine/src/opengl/util.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-15 00:06:07 +0200
committerHampusM <hampus@hampusmat.com>2023-10-15 00:06:07 +0200
commitda329909f93597970afd169cee28ece3bee7127b (patch)
treeb8ce428d458ab5e3e699334877253b10a62c8fe2 /engine/src/opengl/util.rs
parent46f27f31e425f5eba494f499bd7a6ac8f8713c2a (diff)
feat(engine): add logging OpenGL debug messages
Diffstat (limited to 'engine/src/opengl/util.rs')
-rw-r--r--engine/src/opengl/util.rs30
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;