--- /dev/null
+/* $Id$
+
+This file is part of gldbg
+Copyright © 2010 Mikko Rasa, Mikkosoft Productions
+Distributed under the GPL
+*/
+
+#include <dlfcn.h>
+#include "arraysize.h"
+#include "functions.h"
+#include "glwrap.h"
+#include "opengl.h"
+
+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;
+
+ begin_packet(FUNC_GLGETERROR);
+ write_int(ret);
+ send_packet();
+
+ return ret;
+}
+
+void (*eglGetProcAddress(const char *procname))(void)
+{
+ void *handle = 0;
+ void (*ret)() = 0;
+
+ if(glsym((const char *)procname))
+ {
+ handle = dlopen(NULL, RTLD_LAZY);
+ ret = dlsym(handle, (const char *)procname);
+ }
+
+ begin_packet(FUNC_EGLGETPROCADDRESS);
+ write_pointer(ret);
+ write_string((const char *)procname);
+ send_packet();
+
+ return ret;
+}
+
+#include "gensrc/glwrap.funcs"