Gtk: Remove option to disable OpenGL.

OpenGL is the optimal display mode until Vulkan is in, and it's
mandatory on Wayland. Don't let it be disabled.
This commit is contained in:
BearOso 2022-04-19 17:22:42 -05:00
parent 1085ed6fad
commit 3c729a9763
8 changed files with 20 additions and 70 deletions

View File

@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
project(snes9x-gtk VERSION 1.61) project(snes9x-gtk VERSION 1.61)
option(USE_OPENGL "Build support for OpenGL" ON)
option(USE_SLANG "Build support for slang-type shaders" ON) option(USE_SLANG "Build support for slang-type shaders" ON)
option(USE_XV "Build support for XVideo output" ON) option(USE_XV "Build support for XVideo output" ON)
option(USE_PORTAUDIO "Build PortAudio sound driver" ON) option(USE_PORTAUDIO "Build PortAudio sound driver" ON)
@ -56,17 +55,14 @@ find_library(DL dl REQUIRED)
list(APPEND ARGS ${SDL2_CFLAGS} ${GTK_CFLAGS} ${XRANDR_CFLAGS}) list(APPEND ARGS ${SDL2_CFLAGS} ${GTK_CFLAGS} ${XRANDR_CFLAGS})
list(APPEND LIBS ${X11} ${XEXT} ${DL} ${SDL2_LIBRARIES} ${GTK_LIBRARIES} ${XRANDR_LIBRARIES}) list(APPEND LIBS ${X11} ${XEXT} ${DL} ${SDL2_LIBRARIES} ${GTK_LIBRARIES} ${XRANDR_LIBRARIES})
if(USE_OPENGL) pkg_check_modules(EPOXY REQUIRED epoxy)
pkg_check_modules(EPOXY REQUIRED epoxy) list(APPEND ARGS ${EPOXY_CFLAGS})
list(APPEND ARGS ${EPOXY_CFLAGS}) list(APPEND LIBS ${EPOXY_LIBRARIES})
list(APPEND LIBS ${EPOXY_LIBRARIES}) list(APPEND SOURCES src/gtk_display_driver_opengl.cpp
list(APPEND SOURCES src/gtk_display_driver_opengl.cpp src/gtk_glx_context.cpp
src/gtk_glx_context.cpp ../shaders/glsl.cpp
../shaders/glsl.cpp ../shaders/shader_helpers.cpp
../shaders/shader_helpers.cpp src/gtk_shader_parameters.cpp)
src/gtk_shader_parameters.cpp)
list(APPEND DEFINES "USE_OPENGL")
endif()
if(USE_SLANG) if(USE_SLANG)
list(APPEND SOURCES ../shaders/slang.cpp) list(APPEND SOURCES ../shaders/slang.cpp)

View File

@ -52,28 +52,18 @@ deps += dl_dep
xrandr_dep = dependency('xrandr') xrandr_dep = dependency('xrandr')
deps += xrandr_dep deps += xrandr_dep
opengl = get_option('opengl') opengl_dep = dependency('epoxy', required: true)
if opengl srcs += [ 'src/gtk_display_driver_opengl.cpp',
opengl_dep = dependency('epoxy', required: false) 'src/gtk_display_driver_opengl.h',
'src/gtk_glx_context.cpp',
if opengl_dep.found() 'src/gtk_glx_context.h',
args += '-DUSE_OPENGL' '../shaders/glsl.cpp',
srcs += [ 'src/gtk_display_driver_opengl.cpp', '../shaders/shader_helpers.cpp',
'src/gtk_display_driver_opengl.h', 'src/gtk_shader_parameters.cpp' ]
'src/gtk_glx_context.cpp', deps += opengl_dep
'src/gtk_glx_context.h',
'../shaders/glsl.cpp',
'../shaders/shader_helpers.cpp',
'src/gtk_shader_parameters.cpp' ]
deps += opengl_dep
else
opengl = false
warns += 'libepoxy not found. OpenGL will disabled.'
endif
endif
slang = get_option('slang') slang = get_option('slang')
if slang and opengl if slang
cmake = import('cmake') cmake = import('cmake')
@ -397,8 +387,7 @@ summary = [
' localedir: ' + localedir, ' localedir: ' + localedir,
'[Options] Build type: ' + get_option('buildtype'), '[Options] Build type: ' + get_option('buildtype'),
' Wayland: ' + wayland.to_string(), ' Wayland: ' + wayland.to_string(),
' OpenGL: ' + opengl.to_string(), ' slang shaders: ' + slang.to_string(),
' slang shaders: ' + slang.to_string(),
' XVideo: ' + xv.to_string(), ' XVideo: ' + xv.to_string(),
' ALSA: ' + alsa.to_string(), ' ALSA: ' + alsa.to_string(),
' Open Sound System: ' + oss.to_string(), ' Open Sound System: ' + oss.to_string(),

View File

@ -1,4 +1,3 @@
option('opengl', type: 'boolean', value: true, description: 'Build support for OpenGL')
option('slang', type: 'boolean', value: true, description: 'Build support for slang-type shaders') option('slang', type: 'boolean', value: true, description: 'Build support for slang-type shaders')
option('xv', type: 'boolean', value: true, description: 'Build support for XV') option('xv', type: 'boolean', value: true, description: 'Build support for XV')
option('portaudio', type: 'boolean', value: true, description: 'Build PortAudio sound driver') option('portaudio', type: 'boolean', value: true, description: 'Build PortAudio sound driver')

View File

@ -148,7 +148,6 @@ int Snes9xConfig::load_defaults()
rewind_buffer_size = 0; rewind_buffer_size = 0;
Settings.Rewinding = false; Settings.Rewinding = false;
#ifdef USE_OPENGL
sync_to_vblank = true; sync_to_vblank = true;
use_pbos = true; use_pbos = true;
pbo_format = 0; pbo_format = 0;
@ -157,7 +156,6 @@ int Snes9xConfig::load_defaults()
shader_filename.clear(); shader_filename.clear();
use_glfinish = false; use_glfinish = false;
use_sync_control = false; use_sync_control = false;
#endif
/* Snes9x Variables */ /* Snes9x Variables */
Settings.MouseMaster = true; Settings.MouseMaster = true;
@ -255,7 +253,6 @@ int Snes9xConfig::save_config_file()
outbool("MergeFields", ntsc_setup.merge_fields); outbool("MergeFields", ntsc_setup.merge_fields);
outint("ScanlineIntensity", ntsc_scanline_intensity); outint("ScanlineIntensity", ntsc_scanline_intensity);
#ifdef USE_OPENGL
section = "OpenGL"; section = "OpenGL";
outbool("VSync", sync_to_vblank); outbool("VSync", sync_to_vblank);
outbool("glFinish", use_glfinish); outbool("glFinish", use_glfinish);
@ -265,7 +262,6 @@ int Snes9xConfig::save_config_file()
outbool("UsePixelBufferObjects", use_pbos); outbool("UsePixelBufferObjects", use_pbos);
outint("PixelBufferObjectBitDepth", pbo_format); outint("PixelBufferObjectBitDepth", pbo_format);
outstring("ShaderFile", shader_filename); outstring("ShaderFile", shader_filename);
#endif
section = "Sound"; section = "Sound";
outbool("MuteSound", mute_sound); outbool("MuteSound", mute_sound);
@ -489,7 +485,6 @@ int Snes9xConfig::load_config_file()
inbool("MergeFields", ntsc_setup.merge_fields); inbool("MergeFields", ntsc_setup.merge_fields);
inint("ScanlineIntensity", ntsc_scanline_intensity); inint("ScanlineIntensity", ntsc_scanline_intensity);
#ifdef USE_OPENGL
section = "OpenGL"; section = "OpenGL";
inbool("VSync", sync_to_vblank); inbool("VSync", sync_to_vblank);
inbool("glFinish", use_glfinish); inbool("glFinish", use_glfinish);
@ -499,7 +494,6 @@ int Snes9xConfig::load_config_file()
inbool("UseNonPowerOfTwoTextures", npot_textures); inbool("UseNonPowerOfTwoTextures", npot_textures);
inbool("EnableCustomShaders", use_shaders); inbool("EnableCustomShaders", use_shaders);
instr("ShaderFile", shader_filename); instr("ShaderFile", shader_filename);
#endif
section = "Sound"; section = "Sound";
inbool("MuteSound", mute_sound); inbool("MuteSound", mute_sound);
@ -663,10 +657,8 @@ int Snes9xConfig::load_config_file()
scale_method = 0; scale_method = 0;
#endif /* USE_XBRZ */ #endif /* USE_XBRZ */
#ifdef USE_OPENGL
if (pbo_format != 32) if (pbo_format != 32)
pbo_format = 16; pbo_format = 16;
#endif
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC) if (Settings.SkipFrames == THROTTLE_SOUND_SYNC)
Settings.SoundSync = true; Settings.SoundSync = true;

View File

@ -154,7 +154,6 @@ class Snes9xConfig
XRRScreenResources *xrr_screen_resources; XRRScreenResources *xrr_screen_resources;
XRRCrtcInfo *xrr_crtc_info; XRRCrtcInfo *xrr_crtc_info;
#ifdef USE_OPENGL
bool sync_to_vblank; bool sync_to_vblank;
bool use_pbos; bool use_pbos;
int pbo_format; int pbo_format;
@ -163,8 +162,6 @@ class Snes9xConfig
std::string shader_filename; std::string shader_filename;
bool use_glfinish; bool use_glfinish;
bool use_sync_control; bool use_sync_control;
#endif
JoyDevices joysticks; JoyDevices joysticks;
int joystick_threshold; int joystick_threshold;

View File

@ -23,9 +23,7 @@
#include "gtk_display_driver_xv.h" #include "gtk_display_driver_xv.h"
#endif #endif
#ifdef USE_OPENGL
#include "gtk_display_driver_opengl.h" #include "gtk_display_driver_opengl.h"
#endif
static S9xDisplayDriver *driver; static S9xDisplayDriver *driver;
static snes_ntsc_t snes_ntsc; static snes_ntsc_t snes_ntsc;
@ -1299,11 +1297,7 @@ void S9xQueryDrivers()
gui_config->allow_xv = S9xXVDisplayDriver::query_availability(); gui_config->allow_xv = S9xXVDisplayDriver::query_availability();
#endif #endif
#ifdef USE_OPENGL
gui_config->allow_opengl = S9xOpenGLDisplayDriver::query_availability(); gui_config->allow_opengl = S9xOpenGLDisplayDriver::query_availability();
#else
gui_config->allow_opengl = false;
#endif
gui_config->allow_xrandr = false; gui_config->allow_xrandr = false;
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
@ -1414,11 +1408,9 @@ static void S9xInitDriver()
switch (gui_config->hw_accel) switch (gui_config->hw_accel)
{ {
#ifdef USE_OPENGL
case HWA_OPENGL: case HWA_OPENGL:
driver = new S9xOpenGLDisplayDriver(top_level, gui_config); driver = new S9xOpenGLDisplayDriver(top_level, gui_config);
break; break;
#endif
#if defined(USE_XV) && defined(GDK_WINDOWING_X11) #if defined(USE_XV) && defined(GDK_WINDOWING_X11)
case HWA_XV: case HWA_XV:

View File

@ -333,7 +333,6 @@ bool Snes9xPreferences::key_pressed(GdkEventKey *event)
void Snes9xPreferences::shader_select() void Snes9xPreferences::shader_select()
{ {
#ifdef USE_OPENGL
auto entry = get_object<Gtk::Entry>("fragment_shader"); auto entry = get_object<Gtk::Entry>("fragment_shader");
auto dialog = Gtk::FileChooserDialog(*window.get(), _("Select Shader File")); auto dialog = Gtk::FileChooserDialog(*window.get(), _("Select Shader File"));
@ -357,7 +356,6 @@ void Snes9xPreferences::shader_select()
if (!filename.empty()) if (!filename.empty())
entry->set_text(filename); entry->set_text(filename);
} }
#endif
} }
void Snes9xPreferences::load_ntsc_settings() void Snes9xPreferences::load_ntsc_settings()
@ -467,7 +465,6 @@ void Snes9xPreferences::move_settings_to_dialog()
set_combo ("frameskip_combo", Settings.SkipFrames); set_combo ("frameskip_combo", Settings.SkipFrames);
set_check ("bilinear_filter", Settings.BilinearFilter); set_check ("bilinear_filter", Settings.BilinearFilter);
#ifdef USE_OPENGL
set_check ("sync_to_vblank", config->sync_to_vblank); set_check ("sync_to_vblank", config->sync_to_vblank);
set_check ("use_glfinish", config->use_glfinish); set_check ("use_glfinish", config->use_glfinish);
set_check ("use_sync_control", config->use_sync_control); set_check ("use_sync_control", config->use_sync_control);
@ -476,7 +473,7 @@ void Snes9xPreferences::move_settings_to_dialog()
set_check ("npot_textures", config->npot_textures); set_check ("npot_textures", config->npot_textures);
set_check ("use_shaders", config->use_shaders); set_check ("use_shaders", config->use_shaders);
set_entry_text ("fragment_shader", config->shader_filename.c_str ()); set_entry_text ("fragment_shader", config->shader_filename.c_str ());
#endif
set_spin ("joystick_threshold", config->joystick_threshold); set_spin ("joystick_threshold", config->joystick_threshold);
/* Control bindings */ /* Control bindings */
@ -631,7 +628,6 @@ void Snes9xPreferences::get_settings_from_dialog()
Settings.InterpolationMethod = get_combo("sound_filter"); Settings.InterpolationMethod = get_combo("sound_filter");
#endif #endif
#ifdef USE_OPENGL
int pbo_format = get_combo("pixel_format") == 1 ? 32 : 16; int pbo_format = get_combo("pixel_format") == 1 ? 32 : 16;
if (config->sync_to_vblank != get_check("sync_to_vblank") || if (config->sync_to_vblank != get_check("sync_to_vblank") ||
@ -653,7 +649,6 @@ void Snes9xPreferences::get_settings_from_dialog()
config->use_sync_control = get_check("use_sync_control"); config->use_sync_control = get_check("use_sync_control");
config->shader_filename = get_entry_text ("fragment_shader"); config->shader_filename = get_entry_text ("fragment_shader");
config->pbo_format = pbo_format; config->pbo_format = pbo_format;
#endif
std::string new_sram_directory = get_entry_text("sram_directory"); std::string new_sram_directory = get_entry_text("sram_directory");
config->savestate_directory = get_entry_text("savestate_directory"); config->savestate_directory = get_entry_text("savestate_directory");

View File

@ -16,9 +16,7 @@
#include <X11/extensions/Xvlib.h> #include <X11/extensions/Xvlib.h>
#endif #endif
#ifdef USE_OPENGL
#include "gtk_shader_parameters.h" #include "gtk_shader_parameters.h"
#endif
#include "gtk_s9x.h" #include "gtk_s9x.h"
#include "gtk_preferences.h" #include "gtk_preferences.h"
@ -99,13 +97,7 @@ Snes9xWindow::Snes9xWindow(Snes9xConfig *config)
gtk_widget_realize(GTK_WIDGET(window->gobj())); gtk_widget_realize(GTK_WIDGET(window->gobj()));
gtk_widget_realize(GTK_WIDGET(drawing_area->gobj())); gtk_widget_realize(GTK_WIDGET(drawing_area->gobj()));
#ifndef USE_OPENGL
get_object<Gtk::Widget>("shader_parameters_separator")->hide();
get_object<Gtk::Widget>("shader_parameters_item")->hide();
#else
enable_widget("shader_parameters_item", false); enable_widget("shader_parameters_item", false);
#endif
connect_signals(); connect_signals();
@ -180,11 +172,9 @@ void Snes9xWindow::connect_signals()
S9xReset(); S9xReset();
}); });
#ifdef USE_OPENGL
get_object<Gtk::MenuItem>("shader_parameters_item")->signal_activate().connect([&] { get_object<Gtk::MenuItem>("shader_parameters_item")->signal_activate().connect([&] {
gtk_shader_parameters_dialog(get_window()); gtk_shader_parameters_dialog(get_window());
}); });
#endif
const std::vector<const char *> port_items = { "joypad1", "mouse1", "superscope1", "joypad2", "mouse2", "multitap2", "superscope2", "nothingpluggedin2" }; const std::vector<const char *> port_items = { "joypad1", "mouse1", "superscope1", "joypad2", "mouse2", "multitap2", "superscope2", "nothingpluggedin2" };
for (auto &name : port_items) for (auto &name : port_items)