diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp index 9205aa9f2..92cf065f0 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp @@ -49,7 +49,16 @@ GLEScontext* getGLESContext(); #define tls_thread EglThreadInfo::get() -EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance(); +EglGlobalInfo* g_eglInfo = NULL; +android::Mutex s_eglLock; + +void initGlobalInfo() +{ + android::Mutex::Autolock mutex(s_eglLock); + if (!g_eglInfo) { + g_eglInfo = EglGlobalInfo::getInstance(); + } +} static EGLiface s_eglIface = { getGLESContext : getGLESContext, @@ -144,6 +153,7 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { EglDisplay* dpy = NULL; EGLNativeInternalDisplayType internalDisplay = NULL; + initGlobalInfo(); if ((dpy = g_eglInfo->getDisplay(display_id))) { return dpy; @@ -185,6 +195,9 @@ static __translator_getGLESIfaceFunc loadIfaces(const char* libName){ #endif EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) { + + initGlobalInfo(); + EglDisplay* dpy = g_eglInfo->getDisplay(display); if(!dpy) { RETURN_ERROR(EGL_FALSE,EGL_BAD_DISPLAY); @@ -928,6 +941,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname){ __eglMustCastToProperFunctionPointerType retVal = NULL; + + initGlobalInfo(); + if(!strncmp(procname,"egl",3)) { //EGL proc for(int i=0;i < s_eglExtentionsSize;i++){ if(strcmp(procname,s_eglExtentions[i].name) == 0){ diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp index 0c6b0eef8..76820d6dc 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp @@ -220,7 +220,6 @@ static HDC getDummyDC(EGLNativeInternalDisplayType display,int cfgId){ return dpy; } void initPtrToWglFunctions(){ - HWND hwnd = createDummyWindow(); HDC dpy = GetDC(hwnd); if(!hwnd || !dpy){ @@ -308,7 +307,9 @@ static bool initPixelFormat(HDC dc){ int iPixelFormat; if(s_wglExtProcs->wglChoosePixelFormatARB) { - return s_wglExtProcs->wglChoosePixelFormatARB(dc,NULL, NULL, 1, &iPixelFormat, &numpf); + int i0 = 0; + float f0 = 0.0f; + return s_wglExtProcs->wglChoosePixelFormatARB(dc,&i0, &f0, 1, &iPixelFormat, &numpf); } else { return ChoosePixelFormat(dc,&pfd); }