]> git.tdb.fi Git - gldbg.git/commitdiff
Don't call glGetError between glBegin and glEnd
authorMikko Rasa <tdb@tdb.fi>
Mon, 22 Feb 2010 17:04:14 +0000 (17:04 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 22 Feb 2010 17:04:14 +0000 (17:04 +0000)
source/glwrap.c
source/glwrap.funcs.t

index bf05214b8a09d7ee844d5567626b395b2066f1db..68351143d31aca0567dca79c1d7051a885ced85c 100644 (file)
@@ -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;
 }
 
index 547d53f1529d91fcaeaf766a45b99a2becfb8ce3..eb77b0a7a3e0e5ce15e19101bffcb18ad73e8928 100644 (file)
@@ -1,4 +1,6 @@
 # $Id$
+!handcode glBegin
+!handcode glEnd
 !handcode glGetError
 !handcode glXGetProcAddress
 !handcode glXGetProcAddressARB