From 8e52190221eddf1f3de54a59ad26702f49a289b5 Mon Sep 17 00:00:00 2001 From: thesource Date: Mon, 15 Jul 2024 10:59:21 +0300 Subject: [PATCH] GTK: add OpenGL ES support --- desmume/src/frontend/posix/gtk/graphics.ui | 1 + desmume/src/frontend/posix/gtk/main.cpp | 22 ++++++++++++++++++---- desmume/src/frontend/posix/meson.build | 9 +++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/desmume/src/frontend/posix/gtk/graphics.ui b/desmume/src/frontend/posix/gtk/graphics.ui index f8dc2976b..e71bd9a64 100644 --- a/desmume/src/frontend/posix/gtk/graphics.ui +++ b/desmume/src/frontend/posix/gtk/graphics.ui @@ -65,6 +65,7 @@ Null SoftRasterizer OpenGL + OpenGL ES diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index a9ad5b3aa..c42ca3403 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -79,6 +79,10 @@ #include "OGLRender_3_2.h" #endif +#ifdef HAVE_GLES3 + #include "OGLRender_ES3.h" +#endif + #if defined(HAVE_LIBOSMESA) #include "osmesa_3Demu.h" #else @@ -349,6 +353,9 @@ GPU3DInterface *core3DList[] = { #ifdef HAVE_OPENGL &gpu3Dgl, #endif +#ifdef HAVE_GLES3 + &gpu3Dgl_ES_3_0, +#endif }; int multisampleSizes[] = {0, 2, 4, 8, 16, 32}; @@ -2229,9 +2236,11 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g wHCInterpolate = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "hc_interpolate")); g_object_unref(builder); +#ifndef HAVE_GLES3 + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(coreCombo), 3); +#endif #ifndef HAVE_OPENGL gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(coreCombo), 2); - gtk_grid_remove_row(wGrid, 4); #endif gtk_combo_box_set_active(coreCombo, cur3DCore); @@ -2270,7 +2279,7 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g // Change only if needed if (sel3DCore != cur3DCore) { - if (sel3DCore == 2) + if (sel3DCore >= 2) { #if !defined(HAVE_OPENGL) sel3DCore = RENDERID_SOFTRASTERIZER; @@ -3819,6 +3828,11 @@ common_gtk_main(GApplication *app, gpointer user_data) OGLCreateRenderer_3_2_Func = OGLCreateRenderer_3_2; #endif +#if defined(HAVE_GLES3) && defined(OGLRENDER_ES3_H) + OGLLoadEntryPoints_ES_3_0_Func = OGLLoadEntryPoints_ES_3_0; + OGLCreateRenderer_ES_3_0_Func = OGLCreateRenderer_ES_3_0; +#endif + //Set the 3D emulation to use int core = my_config->engine_3d; // setup the gdk 3D emulation; @@ -3829,7 +3843,7 @@ common_gtk_main(GApplication *app, gpointer user_data) core = config.core3D; // Check if it is valid - if (!(core >= 0 && core <= 2)) { + if (!(core >= 0 && core <= 3)) { // If it is invalid, reset it to SoftRasterizer core = 1; } @@ -3837,7 +3851,7 @@ common_gtk_main(GApplication *app, gpointer user_data) my_config->engine_3d = core; } - if (core == 2) + if (core >= 2) { #if !defined(HAVE_OPENGL) core = RENDERID_SOFTRASTERIZER; diff --git a/desmume/src/frontend/posix/meson.build b/desmume/src/frontend/posix/meson.build index 13bf45a25..f10117780 100644 --- a/desmume/src/frontend/posix/meson.build +++ b/desmume/src/frontend/posix/meson.build @@ -16,6 +16,7 @@ dep_pcap = dependency('pcap') dep_zlib = dependency('zlib') dep_threads = dependency('threads') dep_gl = dependency('gl', required: false) +dep_gles3 = dependency('glesv2', required: false) dep_openal = dependency('openal', required: get_option('openal')) dep_alsa = dependency('alsa', required: false) dep_soundtouch = dependency('soundtouch', required: false) @@ -176,6 +177,14 @@ if dep_gl.found() ] endif +if dep_gles3.found() + dependencies += dep_gles3 + add_global_arguments('-DHAVE_GLES3', language: ['c', 'cpp']) + libdesmume_src += [ + '../../OGLRender_ES3.cpp', + ] +endif + if dep_openal.found() dependencies += dep_openal libdesmume_src += [