#include <string.h>
#include <dlfcn.h>
#include <sys/uio.h>
+#include <X11/Xlib.h>
#include <GL/gl.h>
+#include <GL/glx.h>
#include "functions.h"
static inline void *glsym(const char *sym)
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;
+ begin_packet(FUNC_GLGETERROR);
+ write_int(ret);
+ send_packet();
+ return ret;
+}
+
void (*glXGetProcAddress(const GLubyte *procname))(void)
{
void *handle = dlopen(NULL, RTLD_LAZY);
- return dlsym(handle, (const char *)procname);
+ void (*ret)() = dlsym(handle, (const char *)procname);
+ begin_packet(FUNC_GLXGETPROCADDRESS);
+ write_pointer(ret);
+ write_string(procname);
+ send_packet();
+ return ret;
}
void (*glXGetProcAddressARB(const GLubyte *))(void) __attribute__((alias("glXGetProcAddress")));