1 /**************************************************************************
3 * Copyright 2011 Jose Fonseca
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
32 #define _GNU_SOURCE // for dladdr
39 * Handle to the true OpenGL library.
42 HINSTANCE __libGlHandle = NULL;
44 void *__libGlHandle = RTLD_NEXT;
53 #elif defined(__APPLE__)
60 * Lookup a EGL or GLES symbol
63 __libegl_sym(const char *symbol)
67 /* Always try dlsym before eglGetProcAddress as spec 3.10 says
68 * implementation may choose to also export extension functions
71 proc = dlsym(__libGlHandle, symbol);
72 if (!proc && symbol[0] == 'g' && symbol[1] == 'l')
73 proc = (void *) __eglGetProcAddress(symbol);
79 __getPublicProcAddress(const char *procName)
81 return __libegl_sym(procName);
85 __getPrivateProcAddress(const char *procName)
87 return __libegl_sym(procName);