prefix gl
ignore category VERSION_3_2
ignore category ARB_sync
+ignore function glGetError
:{
: FUNC_NONE,
wl(' FUNC_%s,', func.name.upper())
+: FUNC_GLDERROR = 0x8000
:};
static unsigned read_short(short *, const char *);
static unsigned read_int(int *, const char *);
-static int decode_func(GlDecoder *, short, const char *);
+static int decode_func(GlDecoder *, unsigned short, const char *);
+static int decode_gldfunc(GlDecoder *, unsigned short, const char *);
GlDecoder *gldecoder_new(void *user_data, void (*destroy)(void *))
{
{
unsigned pos = 0;
int pktlen;
- short func;
+ unsigned short func;
int ret;
if(len<sizeof(int)+sizeof(short))
pos += read_short(&func, data+pos);
if(dec)
{
- ret = decode_func(dec, func, data+pos);
+ if(func&0x8000)
+ ret = decode_gldfunc(dec, func, data+pos);
+ else
+ ret = decode_func(dec, func, data+pos);
if(ret<0)
return -1;
}
}
#include "gldecoder.funcs"
+
+static int decode_gldError(GlDecoder *dec, const char *data)
+{
+ unsigned pos = 0;
+ GLenum code;
+ pos += read_int(&code, data);
+ if(dec->gldError)
+ dec->gldError(dec->user_data, code);
+ return pos;
+}
+
+static int decode_gldfunc(GlDecoder *dec, unsigned short func, const char *data)
+{
+ switch(func)
+ {
+ case FUNC_GLDERROR: return decode_gldError(dec, data);
+ default: return -1;
+ }
+}
wl(');')
wl(' return pos;')
wl('}')
-:static int decode_func(GlDecoder *dec, short func, const char *data)
+:static int decode_func(GlDecoder *dec, unsigned short func, const char *data)
:{
: switch(func)
: {
for p in params:
w(', %s', p.ctype)
wl(');')
+: void (*gldError)(void *, GLenum);
:} GlDecoder;
static void init_print(GlDecoder *);
static void glprint_data_free(void *);
+static void print_gldError(void *, GLenum);
GlDecoder *glprint_new(char *buffer, unsigned bufsize)
{
dec = gldecoder_new(gpd, free);
init_print(dec);
+ dec->gldError = print_gldError;
}
char *glprint_get_buffer(GlDecoder *dec)
free(gpd);
}
+static void print_gldError(void *user_data, GLenum code)
+{
+ GlPrintData *gpd = (GlPrintData *)user_data;
+ snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode"));
+}
+
#include "glprint.funcs"
return 1;
}
+GLenum cur_error = GL_NO_ERROR;
+
+static void check_error()
+{
+ GLenum (*orig_glGetError)() = 0;
+ GLenum code;
+ if(!orig_glGetError)
+ orig_glGetError = glsym("glGetError");
+ code = orig_glGetError();
+ if(code!=GL_NO_ERROR)
+ {
+ begin_packet(FUNC_GLDERROR);
+ write_int(code);
+ send_packet();
+ if(cur_error==GL_NO_ERROR)
+ cur_error = code;
+ }
+}
+
+GLenum APIENTRY glGetError()
+{
+ GLenum ret = cur_error;
+ cur_error = GL_NO_ERROR;
+ return ret;
+}
+
void (*glXGetProcAddress(const GLubyte *procname))(void)
{
void *handle = dlopen(NULL, RTLD_LAZY);
else:
wl(' write_pointer(%s);', p.name)
wl(' send_packet();')
+if not func.name.startswith("glX"):
+ wl(' check_error();')
if ret.ctype!='void':
wl(' return ret;')
wl('}')