hrydgard/ppsspp

SDL2 CreateWindow calls all the necessary EGL init/open/close functions

mihailescu2m opened this issue · 2 comments

commit 1c29a16821c31a5c5c70c32e84c0c7e4cf5ef44a
Author: memeka <mihailescu2m@gmail.com>
Date:   Sat Feb 28 12:52:35 2015 +1030

    SDL: initialize EGL only if using SDL1; in SDL2, CreateWindow will also initialize EGL

diff --git a/base/PCMain.cpp b/base/PCMain.cpp
index 536d2fd..c05dc37 100644
--- a/base/PCMain.cpp
+++ b/base/PCMain.cpp
@@ -413,6 +413,10 @@ int main(int argc, char *argv[]) {
                return 1;
        }

+    SDL_version sdl_version;
+    SDL_GetVersion(&sdl_version);
+    bool sdl1 = sdl_version.major == 1;
+
 #ifdef __APPLE__
        // Make sure to request a somewhat modern GL context at least - the
        // latest supported by MacOSX (really, really sad...)
@@ -424,7 +428,7 @@ int main(int argc, char *argv[]) {
 #endif

 #ifdef USING_EGL
-       if (EGL_Open())
+       if (sdl1 && EGL_Open())
                return 1;
 #endif

@@ -552,7 +556,7 @@ int main(int argc, char *argv[]) {
        }

 #ifdef USING_EGL
-       EGL_Init();
+       if (sdl1) EGL_Init();
 #endif

 #ifdef PPSSPP
@@ -850,7 +854,10 @@ int main(int argc, char *argv[]) {
                }

 #ifdef USING_EGL
-               eglSwapBuffers(g_eglDisplay, g_eglSurface);
+        if (sdl1)
+               eglSwapBuffers(g_eglDisplay, g_eglSurface);
+        else
+            SDL_GL_SwapWindow(g_Screen);
 #else
                if (!keys[SDLK_TAB] || t - lastT >= 1.0/60.0)
                {
@@ -877,7 +884,7 @@ int main(int argc, char *argv[]) {
        SDL_CloseAudio();
        NativeShutdown();
 #ifdef USING_EGL
-       EGL_Close();
+       if (sdl1) EGL_Close();
 #endif
        SDL_GL_DeleteContext(glContext);
        SDL_Quit();

I wonder if we even support / need to support SDL 1. Maybe we just remove these things instead?

Should we maybe just call SDL_GL_SwapWindow even when !USING_EGL?

I'm not completely familiar with the targets, but it sounds like we might be able to strip out a lot of the USING_EGL define?

-[Unknown]

Closing as outdated.