Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-08-25 15:47:23 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-25 16:02:34 +0300
commitb43f4fda19b935ebeb144e14bba2fc7c590d2ffb (patch)
treecf163de0fd838b1e8c4aaab6f3c980b077fde90c /source/blender/gpu/opengl/gl_context.cc
parente51c428be64feef0877a957b483aa71e5753b29c (diff)
GL: Add error checking function
This is to ease the debugging process on Apple GL implementation.
Diffstat (limited to 'source/blender/gpu/opengl/gl_context.cc')
-rw-r--r--source/blender/gpu/opengl/gl_context.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
index 11f313f639b..2ac361d28e1 100644
--- a/source/blender/gpu/opengl/gl_context.cc
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -22,6 +22,7 @@
*/
#include "BLI_assert.h"
+#include "BLI_system.h"
#include "BLI_utildefines.h"
#include "GPU_framebuffer.h"
@@ -238,3 +239,37 @@ void GLContext::framebuffer_unregister(struct GPUFrameBuffer *fb)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Error Checking
+ *
+ * This is only useful for implementation that does not support the KHR_debug extension.
+ * \{ */
+
+void GLContext::check_error(const char *info)
+{
+ GLenum error = glGetError();
+
+#define ERROR_CASE(err) \
+ case err: \
+ fprintf(stderr, "GL error: %s : %s\n", #err, info); \
+ BLI_system_backtrace(stderr); \
+ break;
+
+ switch (error) {
+ ERROR_CASE(GL_INVALID_ENUM)
+ ERROR_CASE(GL_INVALID_VALUE)
+ ERROR_CASE(GL_INVALID_OPERATION)
+ ERROR_CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
+ ERROR_CASE(GL_OUT_OF_MEMORY)
+ ERROR_CASE(GL_STACK_UNDERFLOW)
+ ERROR_CASE(GL_STACK_OVERFLOW)
+ case GL_NO_ERROR:
+ break;
+ default:
+ fprintf(stderr, "Unknown GL error: %x : %s", error, info);
+ break;
+ }
+}
+
+/** \} */