2 * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 * DongKyun Yun <dk77.yun@samsung.com>
6 * SangJin Kim <sangjin3.kim@samsung.com>
7 * HyunGoo Kang <hyungoo1.kang@samsung.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy of
10 * this software and associated documentation files (the "Software"), to deal in
11 * the Software without restriction, including without limitation the rights to
12 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 * of the Software, and to permit persons to whom the Software is furnished to do
14 * so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in all
17 * copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 #include "implement.h"
36 EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType native) {
37 EGLBoolean bInvokedWithDefault = EGL_FALSE;
38 if (EGLINTER(global).dlGL == NULL) {
39 if ((EGLINTER(global).dlGL = dlopen(GL_SO_FILENAME, RTLD_NOW | RTLD_GLOBAL)) == NULL) {
40 EGLINTER(SetError)(EGL_BAD_ACCESS);
43 EGLINTER(ResetFnptrs)(&(EGLINTER(global)));
44 EGLINTER(BindFnptrs)(&(EGLINTER(global)));
45 #if defined(PROVIDING_RUNTIME_BINDING)
46 EGLINTER(ResetGLFnptrs)(&(EGLINTER(global)));
49 if (native == EGL_DEFAULT_DISPLAY) {
50 native = XOpenDisplay(NULL);
52 return EGL_NO_DISPLAY;
54 bInvokedWithDefault = EGL_TRUE;
56 EGLDisplay unique = (EGLDisplay)(native);
57 struct DisplayExtra* pDisplay = EGLINTER(LookUpDisplay)(unique);
58 if (pDisplay == NULL) {
59 pDisplay = EGLINTER(InsertDisplay)(unique);
60 if (pDisplay == NULL) {
61 return EGL_NO_DISPLAY;
63 pDisplay->native = native;
64 pDisplay->bInitialized = EGL_FALSE;
65 pDisplay->bInvokedWithDefault = bInvokedWithDefault;
66 pDisplay->pConfigBuffer = NULL;
67 pDisplay->nConfigExtra = 0;
68 pDisplay->pConfigExtra = NULL;
69 pDisplay->pConfigAnswer = NULL;
73 return pDisplay->unique;