src/error.c

changeset 261
bfd15f5a3948
parent 221
14eddd43b3f7
equal deleted inserted replaced
260:2649d04f0287 261:bfd15f5a3948
76 void asc_clear_error(void) { 76 void asc_clear_error(void) {
77 cxBufferClear(&asc_context.error_buffer); 77 cxBufferClear(&asc_context.error_buffer);
78 asc_clear_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); 78 asc_clear_flag(asc_context.flags, ASC_FLAG_HAS_ERROR);
79 } 79 }
80 80
81 void asc_error_gl(unsigned code, const char *message) { 81 void asc_error_gl_(const char *file, unsigned line, unsigned code, const char *message) {
82 const char *glerr; 82 const char *glerr;
83 switch(code) { 83 switch(code) {
84 case GL_NO_ERROR: 84 case GL_NO_ERROR:
85 return; 85 return;
86 case GL_INVALID_ENUM: 86 case GL_INVALID_ENUM:
105 glerr = "stack overflow"; 105 glerr = "stack overflow";
106 break; 106 break;
107 default: 107 default:
108 glerr = "unknown GL error"; 108 glerr = "unknown GL error";
109 } 109 }
110 asc_error("%s - GL Error: %s", message, glerr); 110 asc_error_(file, line, "%s - GL Error: %s", message, glerr);
111 } 111 }
112 112
113 int asc_error_catch_gl(const char *message) { 113 int asc_error_catch_gl_(const char *file, unsigned line, const char *message) {
114 // TODO: a printf-like signature does not hurt 114 // TODO: a printf-like signature does not hurt
115 GLenum error; 115 GLenum error;
116 int ret = 0; 116 int ret = 0;
117 while ((error = glGetError()) != GL_NO_ERROR) { 117 while ((error = glGetError()) != GL_NO_ERROR) {
118 asc_error_gl(error, message); 118 asc_error_gl_(file, line, error, message);
119 ret = 1; 119 ret = 1;
120 } 120 }
121 return ret; 121 return ret;
122 } 122 }

mercurial