From 9a75aabe071fd99a95b3189645ac413173e4483d Mon Sep 17 00:00:00 2001 From: thesource Date: Mon, 15 Jul 2024 11:20:11 +0300 Subject: [PATCH] Fix GLES initialization --- desmume/src/frontend/posix/gtk/main.cpp | 4 ++-- desmume/src/frontend/posix/gtk/sdl_3Demu.cpp | 17 +++++++++++++---- desmume/src/frontend/posix/gtk/sdl_3Demu.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index c42ca3403..a40bb2de2 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -2291,7 +2291,7 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g #else if (!is_sdl_initialized()) { - init_sdl_3Demu(); + init_sdl_3Demu(sel3DCore==3); } #endif } @@ -3863,7 +3863,7 @@ common_gtk_main(GApplication *app, gpointer user_data) #else if (!is_sdl_initialized()) { - init_sdl_3Demu(); + init_sdl_3Demu(core==3); } #endif } diff --git a/desmume/src/frontend/posix/gtk/sdl_3Demu.cpp b/desmume/src/frontend/posix/gtk/sdl_3Demu.cpp index 39c5d0d57..603611d8b 100644 --- a/desmume/src/frontend/posix/gtk/sdl_3Demu.cpp +++ b/desmume/src/frontend/posix/gtk/sdl_3Demu.cpp @@ -50,7 +50,7 @@ bool deinit_sdl_3Demu(void) return ret; } -bool init_sdl_3Demu(void) +bool init_sdl_3Demu(bool useES) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); @@ -59,9 +59,18 @@ bool init_sdl_3Demu(void) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + if(useES) + { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + } + else + { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + } win = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, real_framebuffer_width, real_framebuffer_height, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); diff --git a/desmume/src/frontend/posix/gtk/sdl_3Demu.h b/desmume/src/frontend/posix/gtk/sdl_3Demu.h index 2088263da..a369617b2 100644 --- a/desmume/src/frontend/posix/gtk/sdl_3Demu.h +++ b/desmume/src/frontend/posix/gtk/sdl_3Demu.h @@ -18,7 +18,7 @@ #ifndef SDL_3DEMU_H #define SDL_3DEMU_H -bool init_sdl_3Demu(void); +bool init_sdl_3Demu(bool useES); bool deinit_sdl_3Demu(void); bool is_sdl_initialized(void);