]> git.tdb.fi Git - gldbg.git/blob - flavors/gles2/source/glwrap_funcs.c
Replace per-file license notices with License.txt
[gldbg.git] / flavors / gles2 / source / glwrap_funcs.c
1 #include <dlfcn.h>
2 #include "arraysize.h"
3 #include "breakpoint.h"
4 #include "functions.h"
5 #include "glwrap.h"
6 #include "opengl.h"
7 #include "packet.h"
8
9 GLenum cur_error = GL_NO_ERROR;
10
11 static void check_error()
12 {
13         GLenum (*orig_glGetError)() = NULL;
14         GLenum code;
15
16         if(!orig_glGetError)
17                 orig_glGetError = glsym("glGetError");
18
19         code = orig_glGetError();
20         if(code!=GL_NO_ERROR)
21         {
22                 GlPacket *pkt;
23
24                 pkt = packet_begin(FUNC_GLDERROR);
25                 packet_write_int(pkt, code);
26                 packet_send(pkt, get_out_fd());
27
28                 if(cur_error==GL_NO_ERROR)
29                         cur_error = code;
30         }
31 }
32
33 GLenum APIENTRY glGetError()
34 {
35         GLenum ret = cur_error;
36         cur_error = GL_NO_ERROR;
37         GlPacket *pkt;
38
39         pkt = packet_begin(FUNC_GLGETERROR);
40         packet_write_int(pkt, ret);
41         packet_send(pkt, get_out_fd());
42
43         return ret;
44 }
45
46 void (*eglGetProcAddress(const char *procname))(void)
47 {
48         void *handle = NULL;
49         void (*ret)() = NULL;
50         GlPacket *pkt;
51
52         if(glsym((const char *)procname))
53         {
54                 handle = dlopen(NULL, RTLD_LAZY);
55                 ret = dlsym(handle, (const char *)procname);
56         }
57
58         pkt = packet_begin(FUNC_EGLGETPROCADDRESS);
59         packet_write_pointer(pkt, ret);
60         packet_write_string(pkt, (const char *)procname);
61         packet_send(pkt, get_out_fd());
62
63         return ret;
64 }
65
66 #include "gensrc/glwrap.funcs"