Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mihailescu2m opened this issue Feb 28, 2015 · 2 comments
Closed
Labels
SDL2 Issue on SDL (or Qt in SDL code) but not all ports.

Comments

@mihailescu2m
Copy link

commit 1c29a16821c31a5c5c70c32e84c0c7e4cf5ef44a
Author: memeka <[email protected]>
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();
@mihailescu2m mihailescu2m changed the title SDL2 CreateWindow calls all the necessary EGL init/open/close function SDL2 CreateWindow calls all the necessary EGL init/open/close functions Feb 28, 2015
@unknownbrackets
Copy link
Collaborator

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]

@unknownbrackets unknownbrackets added the SDL2 Issue on SDL (or Qt in SDL code) but not all ports. label Dec 23, 2015
@hrydgard
Copy link
Owner

hrydgard commented Sep 3, 2022

Closing as outdated.

@hrydgard hrydgard closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDL2 Issue on SDL (or Qt in SDL code) but not all ports.
Projects
None yet
Development

No branches or pull requests

3 participants