diff --git a/cmake/Options.cmake b/cmake/Options.cmake index f366f9f8..8473becd 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -76,6 +76,14 @@ option(ENABLE_LZMA "Enable LZMA archive support" ON) if(ENABLE_SDL3) set(CMAKE_C_FLAGS "-DENABLE_SDL3 ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-DENABLE_SDL3 ${CMAKE_CXX_FLAGS}") + + include(CheckSymbolExists) + check_symbol_exists(SDL_SCALEMODE_PIXELART "SDL3/SDL.h" HAVE_SDL_SCALEMODE_PIXELART) + + if(HAVE_SDL_SCALEMODE_PIXELART) + set(CMAKE_C_FLAGS "-DHAVE_SDL3_PIXELART ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-DHAVE_SDL3_PIXELART ${CMAKE_CXX_FLAGS}") + endif() endif() if(DISABLE_OPENGL) diff --git a/src/wx/config/internal/option-internal.cpp b/src/wx/config/internal/option-internal.cpp index ad8fc4d8..970e1f5b 100644 --- a/src/wx/config/internal/option-internal.cpp +++ b/src/wx/config/internal/option-internal.cpp @@ -151,6 +151,7 @@ std::array& Option::All() { struct OwnedOptions { /// Display bool bilinear = true; + bool sdl_pixel_art = false; Filter filter = Filter::kNone; wxString filter_plugin = wxEmptyString; Interframe interframe = Interframe::kNone; @@ -280,6 +281,7 @@ std::array& Option::All() { static std::array g_all_opts = { /// Display Option(OptionID::kDispBilinear, &g_owned_opts.bilinear), + Option(OptionID::kDispSDLPixelArt, &g_owned_opts.sdl_pixel_art), Option(OptionID::kDispFilter, &g_owned_opts.filter), Option(OptionID::kDispFilterPlugin, &g_owned_opts.filter_plugin), Option(OptionID::kDispIFB, &g_owned_opts.interframe), @@ -427,6 +429,7 @@ namespace internal { const std::array kAllOptionsData = { /// Display OptionData{"Display/Bilinear", "Bilinear", _("Use bilinear filter with 3d renderer")}, + OptionData{"Display/SDLPixelArt", "SDLPixelArt", _("Use the SDL pixel art filter with an SDL renderer")}, OptionData{"Display/Filter", "", _("Full-screen filter to apply")}, OptionData{"Display/FilterPlugin", "", _("Filter plugin library")}, OptionData{"Display/IFB", "", _("Interframe blending function")}, diff --git a/src/wx/config/option-id.h b/src/wx/config/option-id.h index aa1afc33..d73f6622 100644 --- a/src/wx/config/option-id.h +++ b/src/wx/config/option-id.h @@ -8,6 +8,7 @@ namespace config { enum class OptionID { /// Display kDispBilinear = 0, + kDispSDLPixelArt, kDispFilter, kDispFilterPlugin, kDispIFB, diff --git a/src/wx/config/option-proxy.h b/src/wx/config/option-proxy.h index 263c2e2e..b370e030 100644 --- a/src/wx/config/option-proxy.h +++ b/src/wx/config/option-proxy.h @@ -12,6 +12,7 @@ namespace config { static constexpr std::array kOptionsTypes = { /// Display /*kDispBilinear*/ Option::Type::kBool, + /*kDispSDLPixelArt*/ Option::Type::kBool, /*kDispFilter*/ Option::Type::kFilter, /*kDispFilterPlugin*/ Option::Type::kString, /*kDispIFB*/ Option::Type::kInterframe, diff --git a/src/wx/dialogs/display-config.cpp b/src/wx/dialogs/display-config.cpp index 9e7a0322..e306a31f 100644 --- a/src/wx/dialogs/display-config.cpp +++ b/src/wx/dialogs/display-config.cpp @@ -386,6 +386,14 @@ DisplayConfig::DisplayConfig(wxWindow* parent) sdlrenderer_selector_ = GetValidatedChild("SDLRenderer"); sdlrenderer_selector_->SetValidator(SDLDevicesValidator()); +#if !defined(ENABLE_SDL3) || !defined(HAVE_SDL3_PIXELART) + GetValidatedChild("SDLPixelArt")->Hide(); +#else + GetValidatedChild("SDLPixelArt") + ->SetValidator( + widgets::OptionBoolValidator(config::OptionID::kDispSDLPixelArt)); +#endif + wxWindow* color_profile_srgb = GetValidatedChild("ColorProfileSRGB"); color_profile_srgb->SetValidator( ColorCorrectionProfileValidator(config::ColorCorrectionProfile::kSRGB)); diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 79cfdea0..61a8f895 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -2577,7 +2577,11 @@ SDL_TEXTUREACCESS_STREAMING, (width * scale), (height * scale)); // Set bilinear or nearest on the texture. #ifdef ENABLE_SDL3 +#ifdef HAVE_SDL3_PIXELART + SDL_SetTextureScaleMode(texture, OPTION(kDispSDLPixelArt) ? SDL_SCALEMODE_PIXELART : OPTION(kDispBilinear) ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST); +#else SDL_SetTextureScaleMode(texture, OPTION(kDispBilinear) ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST); +#endif #else SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, OPTION(kDispBilinear) ? "1" : "0"); #endif diff --git a/src/wx/xrc/DisplayConfig.xrc b/src/wx/xrc/DisplayConfig.xrc index 06755f08..5249eccc 100644 --- a/src/wx/xrc/DisplayConfig.xrc +++ b/src/wx/xrc/DisplayConfig.xrc @@ -170,6 +170,13 @@ wxALL|wxEXPAND 5 + + + + + wxALL|wxEXPAND + 5 + 2 1