summaryrefslogtreecommitdiffstats
path: root/opengl.h
diff options
context:
space:
mode:
authorRichard Grenville <pyxlcy@gmail.com>2013-04-25 09:27:14 +0800
committerRichard Grenville <pyxlcy@gmail.com>2013-04-25 09:27:14 +0800
commit1dd41253b22c78bf3cd4497895c906fe07cb209b (patch)
treed5ac5c4ac9a546ac3cee98bef07a3be1499d14ca /opengl.h
parent39da27613fcfc70764769f5c458183f63a5f3ec5 (diff)
downloadtdebase-1dd41253b22c78bf3cd4497895c906fe07cb209b.tar.gz
tdebase-1dd41253b22c78bf3cd4497895c906fe07cb209b.zip
Misc: Fix wrong description & DEBUG_GLX_ERR
- Fix description of "opengl" VSync. - Add DEBUG_GLX_ERR to check for OpenGL errors. - Update man page.
Diffstat (limited to 'opengl.h')
-rw-r--r--opengl.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/opengl.h b/opengl.h
index 7f6dae696..f6ba09b60 100644
--- a/opengl.h
+++ b/opengl.h
@@ -12,6 +12,54 @@
#include <ctype.h>
+#ifdef DEBUG_GLX_ERR
+
+/**
+ * Get a textual representation of an OpenGL error.
+ */
+static inline const char *
+glx_dump_err_str(GLenum err) {
+ switch (err) {
+ CASESTRRET(GL_NO_ERROR);
+ CASESTRRET(GL_INVALID_ENUM);
+ CASESTRRET(GL_INVALID_VALUE);
+ CASESTRRET(GL_INVALID_OPERATION);
+ CASESTRRET(GL_INVALID_FRAMEBUFFER_OPERATION);
+ CASESTRRET(GL_OUT_OF_MEMORY);
+ CASESTRRET(GL_STACK_UNDERFLOW);
+ CASESTRRET(GL_STACK_OVERFLOW);
+ }
+
+ return NULL;
+}
+
+/**
+ * Check for GLX error.
+ *
+ * http://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/
+ */
+static inline void
+glx_check_err_(session_t *ps, const char *func, int line) {
+ if (!ps->glx_context) return;
+
+ GLenum err = GL_NO_ERROR;
+
+ while (GL_NO_ERROR != (err = glGetError())) {
+ print_timestamp(ps);
+ printf("%s():%d: GLX error ", func, line);
+ const char *errtext = glx_dump_err_str(err);
+ if (errtext) {
+ printf_dbg("%s\n", errtext);
+ }
+ else {
+ printf_dbg("%d\n", err);
+ }
+ }
+}
+
+#define glx_check_err(ps) glx_check_err_(ps, __func__, __LINE__)
+#endif
+
/**
* Check if a word is in string.
*/