show meaningful GL error strings during debugging
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jun 2012 12:27:29 +0000 (12:27 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jun 2012 12:27:29 +0000 (12:27 +0000)
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

index 9d854ba..2f22f00 100644 (file)
@@ -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);
         }