3 This file is part of gldbg
4 Copyright © 2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
10 #include "breakpoint.h"
11 #include "functions.h"
16 static int in_begin_block = 0;
17 static GLenum cur_error = GL_NO_ERROR;
19 static void check_error()
21 static GLenum (*orig_glGetError)() = NULL;
28 orig_glGetError = glsym("glGetError");
30 code = orig_glGetError();
35 pkt = packet_begin(FUNC_GLDERROR);
36 packet_write_int(pkt, code);
37 packet_send(pkt, get_out_fd());
39 if(cur_error==GL_NO_ERROR)
44 void APIENTRY glBegin(GLenum mode)
46 static void (*orig)(GLenum) = NULL;
50 orig = glsym("glBegin");
53 pkt = packet_begin(FUNC_GLBEGIN);
54 packet_write_int(pkt, mode);
55 packet_send(pkt, get_out_fd());
62 static void (*orig)() = NULL;
66 orig = glsym("glEnd");
69 pkt = packet_begin(FUNC_GLEND);
70 packet_send(pkt, get_out_fd());
76 GLenum APIENTRY glGetError()
78 GLenum ret = GL_NO_ERROR;
83 if(cur_error==GL_NO_ERROR)
84 cur_error = GL_INVALID_OPERATION;
89 cur_error = GL_NO_ERROR;
92 pkt = packet_begin(FUNC_GLGETERROR);
93 packet_write_int(pkt, ret);
94 packet_send(pkt, get_out_fd());
99 void (*glXGetProcAddress(const GLubyte *procname))(void)
105 if(glsym((const char *)procname))
107 handle = dlopen(NULL, RTLD_LAZY);
108 ret = dlsym(handle, (const char *)procname);
111 pkt = packet_begin(FUNC_GLXGETPROCADDRESS);
112 packet_write_string(pkt, (const char *)procname);
113 packet_write_pointer(pkt, ret);
114 packet_send(pkt, get_out_fd());
119 void (*glXGetProcAddressARB(const GLubyte *))(void) __attribute__((alias("glXGetProcAddress")));
121 #include "gensrc/glwrap.funcs"