]> git.tdb.fi Git - gldbg.git/blob - flavors/gles2/source/glwrap_funcs.c
Describe some texture parameters when printing
[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 "breakpoint.h"
11 #include "functions.h"
12 #include "glwrap.h"
13 #include "opengl.h"
14 #include "packet.h"
15
16 GLenum cur_error = GL_NO_ERROR;
17
18 static void check_error()
19 {
20         GLenum (*orig_glGetError)() = NULL;
21         GLenum code;
22
23         if(!orig_glGetError)
24                 orig_glGetError = glsym("glGetError");
25
26         code = orig_glGetError();
27         if(code!=GL_NO_ERROR)
28         {
29                 GlPacket *pkt;
30
31                 pkt = packet_begin(FUNC_GLDERROR);
32                 packet_write_int(pkt, code);
33                 packet_send(pkt, get_out_fd());
34
35                 if(cur_error==GL_NO_ERROR)
36                         cur_error = code;
37         }
38 }
39
40 GLenum APIENTRY glGetError()
41 {
42         GLenum ret = cur_error;
43         cur_error = GL_NO_ERROR;
44         GlPacket *pkt;
45
46         pkt = packet_begin(FUNC_GLGETERROR);
47         packet_write_int(pkt, ret);
48         packet_send(pkt, get_out_fd());
49
50         return ret;
51 }
52
53 void (*eglGetProcAddress(const char *procname))(void)
54 {
55         void *handle = NULL;
56         void (*ret)() = NULL;
57         GlPacket *pkt;
58
59         if(glsym((const char *)procname))
60         {
61                 handle = dlopen(NULL, RTLD_LAZY);
62                 ret = dlsym(handle, (const char *)procname);
63         }
64
65         pkt = packet_begin(FUNC_EGLGETPROCADDRESS);
66         packet_write_pointer(pkt, ret);
67         packet_write_string(pkt, (const char *)procname);
68         packet_send(pkt, get_out_fd());
69
70         return ret;
71 }
72
73 #include "gensrc/glwrap.funcs"