From: Mikko Rasa Date: Mon, 22 Feb 2010 17:04:14 +0000 (+0000) Subject: Don't call glGetError between glBegin and glEnd X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=27a82684df128955f6c4e1467935be14ff9bb816;p=gldbg.git Don't call glGetError between glBegin and glEnd --- diff --git a/source/glwrap.c b/source/glwrap.c index bf05214..6835114 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -160,32 +160,79 @@ static inline void send_packet() writev(fd, iovecs, cur_vec-iovecs); } +int in_begin_block = 0; GLenum cur_error = GL_NO_ERROR; static void check_error() { GLenum (*orig_glGetError)() = 0; GLenum code; + + if(in_begin_block) + return; + 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; } } +void APIENTRY glBegin(GLenum mode) +{ + static void (*orig)(GLenum); + if(!orig) + orig = glsym("glBegin"); + orig(mode); + + begin_packet(FUNC_GLBEGIN); + write_int(mode); + send_packet(); + + in_begin_block = 1; +} + +void APIENTRY glEnd() +{ + static void (*orig)(); + if(!orig) + orig = glsym("glEnd"); + orig(); + + begin_packet(FUNC_GLEND); + send_packet(); + + in_begin_block = 0; + check_error(); +} + GLenum APIENTRY glGetError() { - GLenum ret = cur_error; - cur_error = GL_NO_ERROR; + GLenum ret = GL_NO_ERROR; + + if(in_begin_block) + { + if(cur_error==GL_NO_ERROR) + cur_error = GL_INVALID_OPERATION; + } + else + { + ret = cur_error; + cur_error = GL_NO_ERROR; + } + begin_packet(FUNC_GLGETERROR); write_int(ret); send_packet(); + return ret; } diff --git a/source/glwrap.funcs.t b/source/glwrap.funcs.t index 547d53f..eb77b0a 100644 --- a/source/glwrap.funcs.t +++ b/source/glwrap.funcs.t @@ -1,4 +1,6 @@ # $Id$ +!handcode glBegin +!handcode glEnd !handcode glGetError !handcode glXGetProcAddress !handcode glXGetProcAddressARB