src/error.c

changeset 16
c5dde81b6fb2
parent 15
362b7659dc76
child 58
26ebb2f1e6e6
equal deleted inserted replaced
15:362b7659dc76 16:c5dde81b6fb2
28 #include "ascension/context.h" 28 #include "ascension/context.h"
29 #include "ascension/error.h" 29 #include "ascension/error.h"
30 #include "ascension/utils.h" 30 #include "ascension/utils.h"
31 31
32 #include <cx/buffer.h> 32 #include <cx/buffer.h>
33 #include <GL/gl.h>
33 34
34 void asc_error_cchar(char const* text) { 35 void asc_error_cchar(char const* text) {
35 asc_error_cxstr(cx_str(text)); 36 asc_error_cxstr(cx_str(text));
36 } 37 }
37 38
67 68
68 void asc_clear_error(void) { 69 void asc_clear_error(void) {
69 cxBufferClear(&asc_context.error_buffer); 70 cxBufferClear(&asc_context.error_buffer);
70 asc_clear_flag(&asc_context.flags, ASC_FLAG_HAS_ERROR); 71 asc_clear_flag(&asc_context.flags, ASC_FLAG_HAS_ERROR);
71 } 72 }
73
74 void asc_error_gl(unsigned code, cxstring message) {
75 const char *glerr;
76 switch(code) {
77 case GL_NO_ERROR:
78 return;
79 case GL_INVALID_ENUM:
80 glerr = "invalid enum";
81 break;
82 case GL_INVALID_VALUE:
83 glerr = "invalid value";
84 break;
85 case GL_INVALID_OPERATION:
86 glerr = "invalid operation";
87 break;
88 case GL_INVALID_FRAMEBUFFER_OPERATION:
89 glerr = "invalid framebuffer operation";
90 break;
91 case GL_OUT_OF_MEMORY:
92 glerr = "out of memory";
93 break;
94 case GL_STACK_UNDERFLOW:
95 glerr = "stack underflow";
96 break;
97 case GL_STACK_OVERFLOW:
98 glerr = "stack overflow";
99 break;
100 default:
101 glerr = "unknown GL error";
102 }
103 cxmutstr msg = cx_strcat(3, message, CX_STR(" GL Error: "), cx_str(glerr));
104 asc_error_cxstr(cx_strcast(msg));
105 cx_strfree(&msg);
106 }

mercurial