9af6d1d36a6fdc9f898f4c19809a6052b881024e
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 */
23 #include <stdio.h>
24 #include <stdlib.h>
26 //#include <cutils/log.h>
32 #define DEBUG_NANO 0
34 #ifdef __ANDROID__
35 #include <android/log.h>
36 #define LOG __android_log_print
38 #define LOGI( ... ) __android_log_print( ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__ )
39 #define LOGD( ... ) \
40 if ( DEBUG_NANO ) \
41 __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ )
42 #define LOGE( ... ) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
43 #define LOGW( ... ) __android_log_print( ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__ )
44 #else
45 #ifndef _MSC_VER
46 #define LOGI( ... ) \
49 #define LOGD( ... ) \
50 if ( DEBUG_NANO ) \
51 { \
54 }
55 #define LOGE( ... ) \
58 #define LOGW( ... ) \
61 #else
62 #define LOGI printf
63 #define LOGD printf
64 #define LOGE printf
65 #define LOGW printf
67 #endif
68 #endif
70 #ifdef _WIN32
71 #include <windows.h>
72 #define dlopen( x, y ) LoadLibraryA( x )
73 #define dlsym( x, y ) ( void * ) GetProcAddress( (HINSTANCE)x, y )
74 #define dlclose( x ) FreeLibrary( (HINSTANCE)x )
75 #else
76 #include <dlfcn.h>
77 #endif
79 //#define GL_ENTRY(_r, _api, ...) #_api,
83 NULL};
85 //const char * driver;
94 {
95 #ifndef USE_CORE_PROFILE
97 #endif
98 }
100 #ifdef XASH_SDL
102 #endif
105 {
107 #ifdef XASH_SDL
110 #endif
113 }
116 {
117 // alloc space
122 {
124 }
126 // load GL API calls
130 // nanoGL interface pointer
134 {
139 #ifdef USE_CORE_PROFILE
140 // Hack: try ARB and EXT suffix
142 {
146 }
148 {
152 }
153 #endif
155 {
158 // try lib1
160 {
164 {
166 if ( glEsImpl->eglGetProcAddress && ( (void *)glEsImpl->eglGetProcAddress != (void *)gl_unimplemented ) )
170 }
171 else
172 {
174 }
175 }
176 else
177 {
179 if ( glEsImpl->eglGetProcAddress && ( (void *)glEsImpl->eglGetProcAddress != (void *)gl_unimplemented ) )
183 }
184 }
185 else
186 {
188 }
191 api++;
192 }
195 }
197 // Load using the dynamic loader
199 {
203 }
205 /**
206 * Init
207 */
208 #ifdef _WIN32
210 {
216 // load lib
218 //LOG (ANDROID_LOG_DEBUG, LOG_TAG, "nanoGL: Init loading driver %s\n", lib1);
221 {
225 {
228 }
229 else
231 }
232 else
237 //if ( strcmp(driver, lib2) == 0 ) {
243 {
245 }
246 //}
248 // Load API gl* for 1.5+ else egl* gl*
249 //if (CreateGlEsInterface(driver, glesLib, eglLib, NULL) == -1)
251 {
252 // release lib
257 }
259 // Init nanoGL
262 }
263 #else
265 {
271 // load lib
273 //LOG (ANDROID_LOG_DEBUG, LOG_TAG, "nanoGL: Init loading driver %s\n", lib1);
276 {
280 {
283 }
284 else
286 }
287 else
292 //if ( strcmp(driver, lib2) == 0 ) {
298 {
300 }
301 //}
303 // Load API gl* for 1.5+ else egl* gl*
304 //if (CreateGlEsInterface(driver, glesLib, eglLib, NULL) == -1)
306 {
307 // release lib
312 }
314 #ifdef __ANDROID__
315 // somewhy it does not initialize correctly
316 *( (void **)&glEsImpl->glGenFramebuffers ) = (void *)glEsImpl->eglGetProcAddress( "glGenFramebuffersOES" );
317 *( (void **)&glEsImpl->glGenRenderbuffers ) = (void *)glEsImpl->eglGetProcAddress( "glGenRenderbuffersOES" );
318 *( (void **)&glEsImpl->glRenderbufferStorage ) = (void *)glEsImpl->eglGetProcAddress( "glRenderbufferStorageOES" );
319 *( (void **)&glEsImpl->glBindFramebuffer ) = (void *)glEsImpl->eglGetProcAddress( "glBindFramebufferOES" );
320 *( (void **)&glEsImpl->glBindRenderbuffer ) = (void *)glEsImpl->eglGetProcAddress( "glBindRenderbufferOES" );
321 *( (void **)&glEsImpl->glFramebufferTexture2D ) = (void *)glEsImpl->eglGetProcAddress( "glFramebufferTexture2DOES" );
322 *( (void **)&glEsImpl->glDeleteRenderbuffers ) = (void *)glEsImpl->eglGetProcAddress( "glDeleteRenderbuffersOES" );
323 *( (void **)&glEsImpl->glDeleteFramebuffers ) = (void *)glEsImpl->eglGetProcAddress( "glDeleteFramebuffersOES" );
324 *( (void **)&glEsImpl->glFramebufferRenderbuffer ) = (void *)glEsImpl->eglGetProcAddress( "glFramebufferRenderbufferOES" );
325 #endif
327 // Init nanoGL
330 }
331 #endif
333 {
337 {
340 }
342 // release lib
344 }