/* * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * DongKyun Yun * SangJin Kim * HyunGoo Kang * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Contributors: * - S-Core Co., Ltd * */ #include "implement.h" #include __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) { void* fpAnswer = NULL; if (procname == NULL) return NULL; if (procname[0] == '\0') return NULL; if (EGLINTER(global).dlEGL == NULL) { if ((EGLINTER(global).dlEGL = dlopen(EGL_SO_FILENAME, RTLD_NOW | RTLD_GLOBAL)) == NULL) { return NULL; } } if ((fpAnswer = dlsym(EGLINTER(global).dlEGL, procname)) != NULL) { return fpAnswer; } void** ptrDLL = NULL; char* sofilename; char* libname; EGLContext eglContext = _eglGetCurrentContext(); if (eglContext != EGL_NO_CONTEXT) { struct ContextExtra* pContext = EGLINTER(LookUpContext)(eglContext); assert(pContext != NULL); switch (pContext->apiKind) { case EGL_OPENGL_API: ptrDLL = &(EGLINTER(global).dlGL); sofilename = GL_SO_FILENAME; libname = "GL"; break; case EGL_OPENGL_ES_API: if (pContext->apiVersion == 2) { ptrDLL = &(EGLINTER(global).dlES2); sofilename = GL_ES2_SO_FILENAME; libname = "ES2"; } else { ptrDLL = &(EGLINTER(global).dlES1); sofilename = GL_ES1_SO_FILENAME; libname = "ES1"; } break; default: return NULL; break; } if (*ptrDLL == NULL) { if ((*ptrDLL = dlopen(sofilename, RTLD_NOW | RTLD_GLOBAL)) == NULL) { return NULL; } } if ((fpAnswer = dlsym(*ptrDLL, procname)) != NULL) { return fpAnswer; } } #if 1 else { ptrDLL = &(EGLINTER(global).dlES2); sofilename = GL_ES2_SO_FILENAME; libname = "ES2"; if (*ptrDLL == NULL) { if ((*ptrDLL = dlopen(sofilename, RTLD_NOW | RTLD_GLOBAL)) == NULL) { return NULL; } } if ((fpAnswer = dlsym(*ptrDLL, procname)) != NULL) { return fpAnswer; } } #endif return NULL; }