3 This file is part of gldbg
4 Copyright © 2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
10 #include "functions.h"
15 static int in_begin_block = 0;
16 static GLenum cur_error = GL_NO_ERROR;
18 static void check_error()
20 static GLenum (*orig_glGetError)() = NULL;
27 orig_glGetError = glsym("glGetError");
29 code = orig_glGetError();
34 pkt = packet_begin(FUNC_GLDERROR);
35 packet_write_int(pkt, code);
36 packet_send(pkt, get_out_fd());
38 if(cur_error==GL_NO_ERROR)
43 void APIENTRY glBegin(GLenum mode)
45 static void (*orig)(GLenum) = NULL;
49 orig = glsym("glBegin");
52 pkt = packet_begin(FUNC_GLBEGIN);
53 packet_write_int(pkt, mode);
54 packet_send(pkt, get_out_fd());
61 static void (*orig)() = NULL;
65 orig = glsym("glEnd");
68 pkt = packet_begin(FUNC_GLEND);
69 packet_send(pkt, get_out_fd());
75 GLenum APIENTRY glGetError()
77 GLenum ret = GL_NO_ERROR;
82 if(cur_error==GL_NO_ERROR)
83 cur_error = GL_INVALID_OPERATION;
88 cur_error = GL_NO_ERROR;
91 pkt = packet_begin(FUNC_GLGETERROR);
92 packet_write_int(pkt, ret);
93 packet_send(pkt, get_out_fd());
98 void (*glXGetProcAddress(const GLubyte *procname))(void)
104 if(glsym((const char *)procname))
106 handle = dlopen(NULL, RTLD_LAZY);
107 ret = dlsym(handle, (const char *)procname);
110 pkt = packet_begin(FUNC_GLXGETPROCADDRESS);
111 packet_write_string(pkt, (const char *)procname);
112 packet_write_pointer(pkt, ret);
113 packet_send(pkt, get_out_fd());
118 void (*glXGetProcAddressARB(const GLubyte *))(void) __attribute__((alias("glXGetProcAddress")));
120 #include "gensrc/glwrap.funcs"