From 845eafddb09e9a28b45b502abb544df1e286a324 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 18 Jun 2012 12:27:29 +0000 Subject: [PATCH] show meaningful GL error strings during debugging Committed on behalf of Guanqun.Lu@gmail.com Review URL: http://codereview.appspot.com/6306094/ git-svn-id: http://skia.googlecode.com/svn/trunk@4271 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLUtil.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 9d854ba5f6..2f22f00f69 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -8,16 +8,37 @@ #include "GrGLUtil.h" + void GrGLClearErr(const GrGLInterface* gl) { while (GR_GL_NO_ERROR != gl->fGetError()) {} } +namespace { +const char *get_error_string(uint32_t err) { + switch (err) { + case GR_GL_NO_ERROR: + return ""; + case GR_GL_INVALID_ENUM: + return "Invalid Enum"; + case GR_GL_INVALID_VALUE: + return "Invalid Value"; + case GR_GL_INVALID_OPERATION: + return "Invalid Operation"; + case GR_GL_OUT_OF_MEMORY: + return "Out of Memory"; + case GR_GL_CONTEXT_LOST: + return "Context Lost"; + } + return "Unknown"; +} +} + void GrGLCheckErr(const GrGLInterface* gl, const char* location, const char* call) { uint32_t err = GR_GL_GET_ERROR(gl); if (GR_GL_NO_ERROR != err) { - GrPrintf("---- glGetError %x", err); + GrPrintf("---- glGetError 0x%x(%s)", err, get_error_string(err)); if (NULL != location) { GrPrintf(" at\n\t%s", location); }