DEADSOFTWARE

Use SDL for GetProcAddress
[nanogl.git] / eglwrap.cpp
1 /*
2 Copyright (C) 2007-2009 Olli Hinkka
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
22 #include "egl.h"
23 #include "glesinterface.h"
24 #include "gl.h"
26 #include <string.h>
29 extern "C++" GlESInterface* glEsImpl;
30 extern "C++" void FlushOnStateChange();
31 void APIENTRY gl_unimplemented(GLenum none);
33 EGLint eglGetError (void)
34 {
35 return glEsImpl->eglGetError();
36 }
38 EGLDisplay eglGetDisplay (NativeDisplayType display)
39 {
40 return glEsImpl->eglGetDisplay(display);
41 }
43 EGLBoolean eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor)
44 {
45 return glEsImpl->eglInitialize(dpy,major,minor);
46 }
48 EGLBoolean eglTerminate (EGLDisplay dpy)
49 {
50 return glEsImpl->eglTerminate(dpy);
51 }
52 const char * eglQueryString (EGLDisplay dpy, EGLint name)
53 {
54 return glEsImpl->eglQueryString(dpy,name);
55 }
57 #if defined(__MULTITEXTURE_SUPPORT__)
58 extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
59 #endif
61 void * eglGetProcAddress (const char *procname)
62 {
63 #if defined(__MULTITEXTURE_SUPPORT__)
64 if (!strcmp(procname, "glMultiTexCoord2fARB"))
65 {
66 return (void*)&glMultiTexCoord2fARB;
67 }
68 else if (!strcmp(procname, "glActiveTextureARB"))
69 {
70 return (void*)&glActiveTexture;
71 }
72 else if (!strcmp(procname, "glClientActiveTextureARB"))
73 {
74 return (void*)&glClientActiveTexture;
75 }
77 #endif
78 return (void*)glEsImpl->eglGetProcAddress(procname);
79 }
81 EGLBoolean eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
82 {
83 return glEsImpl->eglGetConfigs(dpy,configs, config_size, num_config);
84 }
86 EGLBoolean eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
87 {
88 return glEsImpl->eglChooseConfig(dpy,attrib_list,configs,config_size, num_config);
89 }
91 EGLBoolean eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
92 {
93 return glEsImpl->eglGetConfigAttrib(dpy,config,attribute,value);
94 }
96 EGLSurface eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list)
97 {
98 return glEsImpl->eglCreateWindowSurface(dpy,config,window,attrib_list);
99 }
101 EGLSurface eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list)
103 return glEsImpl->eglCreatePixmapSurface(dpy,config,pixmap,attrib_list);
106 EGLSurface eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
108 return glEsImpl->eglCreatePbufferSurface(dpy, config, attrib_list);
111 EGLBoolean eglDestroySurface (EGLDisplay dpy, EGLSurface surface)
113 return glEsImpl->eglDestroySurface(dpy,surface);
115 EGLBoolean eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
117 return glEsImpl->eglQuerySurface(dpy,surface,attribute,value);
119 /* EGL 1.1 render-to-texture APIs */
120 EGLBoolean eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
122 return glEsImpl->eglSurfaceAttrib(dpy,surface,attribute,value);
125 EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
127 return glEsImpl->eglBindTexImage(dpy,surface,buffer);
129 EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
131 return glEsImpl->eglReleaseTexImage(dpy,surface,buffer);
134 /* EGL 1.1 swap control API */
135 EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
137 return glEsImpl->eglSwapInterval(dpy,interval);
140 EGLContext eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)
142 return glEsImpl->eglCreateContext(dpy,config,share_list,attrib_list);
145 EGLBoolean eglDestroyContext (EGLDisplay dpy, EGLContext ctx)
147 return glEsImpl->eglDestroyContext(dpy,ctx);
150 EGLBoolean eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
152 FlushOnStateChange();
153 return glEsImpl->eglMakeCurrent(dpy,draw,read,ctx);
156 EGLContext eglGetCurrentContext (void)
158 return glEsImpl->eglGetCurrentContext();
160 EGLSurface eglGetCurrentSurface (EGLint readdraw)
162 if( (void*)glEsImpl->eglGetCurrentSurface == (void*)gl_unimplemented )
163 return EGL_NO_SURFACE;
164 return glEsImpl->eglGetCurrentSurface(readdraw);
166 EGLDisplay eglGetCurrentDisplay (void)
168 if( (void*)glEsImpl->eglGetCurrentDisplay == (void*)gl_unimplemented )
169 return EGL_NO_DISPLAY;
170 return glEsImpl->eglGetCurrentDisplay();
173 EGLBoolean eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
175 return glEsImpl->eglQueryContext(dpy,ctx,attribute,value);
178 EGLBoolean eglWaitGL (void)
180 FlushOnStateChange();
181 return glEsImpl->eglWaitGL();
184 EGLBoolean eglWaitNative (EGLint engine)
186 FlushOnStateChange();
187 return glEsImpl->eglWaitNative(engine);
191 EGLBoolean eglSwapBuffers (EGLDisplay dpy, EGLSurface draw)
193 FlushOnStateChange();
194 return glEsImpl->eglSwapBuffers(dpy,draw);
197 EGLBoolean eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target)
199 FlushOnStateChange();
200 return glEsImpl->eglCopyBuffers(dpy,surface,target);