| 26 */ |
26 */ |
| 27 |
27 |
| 28 #include "ascension/context.h" |
28 #include "ascension/context.h" |
| 29 #include "ascension/error.h" |
29 #include "ascension/error.h" |
| 30 |
30 |
| |
31 #include <stdio.h> |
| |
32 #include <stdarg.h> |
| 31 #include <cx/printf.h> |
33 #include <cx/printf.h> |
| 32 |
34 |
| 33 #include <GL/glew.h> |
35 #include <GL/glew.h> |
| 34 |
36 |
| |
37 void asc_printf(const char *level, const char *file, unsigned line, const char *fmt, ...) { |
| |
38 printf("[%s %s %u] ", level, file, line); |
| |
39 va_list ap; |
| |
40 va_start(ap, fmt); |
| |
41 vprintf(fmt, ap); |
| |
42 va_end(ap); |
| |
43 putchar('\n'); |
| |
44 } |
| 35 |
45 |
| 36 void asc_error_impl(const char* file, unsigned line, char const* fmt, ...) { |
46 void asc_error_impl(const char* file, unsigned line, char const* fmt, ...) { |
| 37 asc_set_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); |
47 asc_set_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); |
| 38 |
48 |
| 39 // write to error buffer |
49 // write to error buffer |
| |
50 CxBuffer* buf = &asc_context.error_buffer; |
| |
51 size_t bufpos = buf->pos; |
| 40 va_list args; |
52 va_list args; |
| 41 va_start(args, fmt); |
53 va_start(args, fmt); |
| 42 CxBuffer* buf = &asc_context.error_buffer; |
|
| 43 size_t bufpos = buf->pos; |
|
| 44 int written = cx_vfprintf(buf, cxBufferWriteFunc, fmt, args); |
54 int written = cx_vfprintf(buf, cxBufferWriteFunc, fmt, args); |
| 45 cxBufferPut(buf, '\n'); |
55 cxBufferPut(buf, '\n'); |
| 46 va_end(args); |
56 va_end(args); |
| 47 |
57 |
| 48 // also print to stderr |
58 // also print to stderr |