]> git.tdb.fi Git - gldbg.git/blob - flavors/gles2/source/glwrap_funcs.c
c647753584930e4540739304de99070bd6bb84b3
[gldbg.git] / flavors / gles2 / source / glwrap_funcs.c
1 /* $Id$
2
3 This file is part of gldbg
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
6 */
7
8 #include <dlfcn.h>
9 #include "arraysize.h"
10 #include "functions.h"
11 #include "glwrap.h"
12 #include "opengl.h"
13
14 GLenum cur_error = GL_NO_ERROR;
15
16 static void check_error()
17 {
18         GLenum (*orig_glGetError)() = 0;
19         GLenum code;
20
21         if(!orig_glGetError)
22                 orig_glGetError = glsym("glGetError");
23
24         code = orig_glGetError();
25         if(code!=GL_NO_ERROR)
26         {
27                 begin_packet(FUNC_GLDERROR);
28                 write_int(code);
29                 send_packet();
30
31                 if(cur_error==GL_NO_ERROR)
32                         cur_error = code;
33         }
34 }
35
36 GLenum APIENTRY glGetError()
37 {
38         GLenum ret = cur_error;
39         cur_error = GL_NO_ERROR;
40
41         begin_packet(FUNC_GLGETERROR);
42         write_int(ret);
43         send_packet();
44
45         return ret;
46 }
47
48 void (*eglGetProcAddress(const char *procname))(void)
49 {
50         void *handle = 0;
51         void (*ret)() = 0;
52
53         if(glsym((const char *)procname))
54         {
55                 handle = dlopen(NULL, RTLD_LAZY);
56                 ret = dlsym(handle, (const char *)procname);
57         }
58
59         begin_packet(FUNC_EGLGETPROCADDRESS);
60         write_pointer(ret);
61         write_string((const char *)procname);
62         send_packet();
63
64         return ret;
65 }
66
67 #include "gensrc/glwrap.funcs"