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
This commit is contained in:
bsalomon@google.com 2012-06-18 12:27:29 +00:00
parent fc0d23a6ba
commit 845eafddb0

View 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);
}