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;
}