mirror of
https://github.com/visualboyadvance-m/visualboyadvance-m
synced 2025-10-05 23:52:49 +02:00
Add option to enable SDL pixel art texture filter
Add a checkbox in display config to enable SDL_SCALEMODE_PIXELART when it is available. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
@@ -76,6 +76,14 @@ option(ENABLE_LZMA "Enable LZMA archive support" ON)
|
|||||||
if(ENABLE_SDL3)
|
if(ENABLE_SDL3)
|
||||||
set(CMAKE_C_FLAGS "-DENABLE_SDL3 ${CMAKE_C_FLAGS}")
|
set(CMAKE_C_FLAGS "-DENABLE_SDL3 ${CMAKE_C_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "-DENABLE_SDL3 ${CMAKE_CXX_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()
|
endif()
|
||||||
|
|
||||||
if(DISABLE_OPENGL)
|
if(DISABLE_OPENGL)
|
||||||
|
@@ -151,6 +151,7 @@ std::array<Option, kNbOptions>& Option::All() {
|
|||||||
struct OwnedOptions {
|
struct OwnedOptions {
|
||||||
/// Display
|
/// Display
|
||||||
bool bilinear = true;
|
bool bilinear = true;
|
||||||
|
bool sdl_pixel_art = false;
|
||||||
Filter filter = Filter::kNone;
|
Filter filter = Filter::kNone;
|
||||||
wxString filter_plugin = wxEmptyString;
|
wxString filter_plugin = wxEmptyString;
|
||||||
Interframe interframe = Interframe::kNone;
|
Interframe interframe = Interframe::kNone;
|
||||||
@@ -280,6 +281,7 @@ std::array<Option, kNbOptions>& Option::All() {
|
|||||||
static std::array<Option, kNbOptions> g_all_opts = {
|
static std::array<Option, kNbOptions> g_all_opts = {
|
||||||
/// Display
|
/// Display
|
||||||
Option(OptionID::kDispBilinear, &g_owned_opts.bilinear),
|
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::kDispFilter, &g_owned_opts.filter),
|
||||||
Option(OptionID::kDispFilterPlugin, &g_owned_opts.filter_plugin),
|
Option(OptionID::kDispFilterPlugin, &g_owned_opts.filter_plugin),
|
||||||
Option(OptionID::kDispIFB, &g_owned_opts.interframe),
|
Option(OptionID::kDispIFB, &g_owned_opts.interframe),
|
||||||
@@ -427,6 +429,7 @@ namespace internal {
|
|||||||
const std::array<OptionData, kNbOptions + 1> kAllOptionsData = {
|
const std::array<OptionData, kNbOptions + 1> kAllOptionsData = {
|
||||||
/// Display
|
/// Display
|
||||||
OptionData{"Display/Bilinear", "Bilinear", _("Use bilinear filter with 3d renderer")},
|
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/Filter", "", _("Full-screen filter to apply")},
|
||||||
OptionData{"Display/FilterPlugin", "", _("Filter plugin library")},
|
OptionData{"Display/FilterPlugin", "", _("Filter plugin library")},
|
||||||
OptionData{"Display/IFB", "", _("Interframe blending function")},
|
OptionData{"Display/IFB", "", _("Interframe blending function")},
|
||||||
|
@@ -8,6 +8,7 @@ namespace config {
|
|||||||
enum class OptionID {
|
enum class OptionID {
|
||||||
/// Display
|
/// Display
|
||||||
kDispBilinear = 0,
|
kDispBilinear = 0,
|
||||||
|
kDispSDLPixelArt,
|
||||||
kDispFilter,
|
kDispFilter,
|
||||||
kDispFilterPlugin,
|
kDispFilterPlugin,
|
||||||
kDispIFB,
|
kDispIFB,
|
||||||
|
@@ -12,6 +12,7 @@ namespace config {
|
|||||||
static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
|
static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
|
||||||
/// Display
|
/// Display
|
||||||
/*kDispBilinear*/ Option::Type::kBool,
|
/*kDispBilinear*/ Option::Type::kBool,
|
||||||
|
/*kDispSDLPixelArt*/ Option::Type::kBool,
|
||||||
/*kDispFilter*/ Option::Type::kFilter,
|
/*kDispFilter*/ Option::Type::kFilter,
|
||||||
/*kDispFilterPlugin*/ Option::Type::kString,
|
/*kDispFilterPlugin*/ Option::Type::kString,
|
||||||
/*kDispIFB*/ Option::Type::kInterframe,
|
/*kDispIFB*/ Option::Type::kInterframe,
|
||||||
|
@@ -386,6 +386,14 @@ DisplayConfig::DisplayConfig(wxWindow* parent)
|
|||||||
sdlrenderer_selector_ = GetValidatedChild<wxChoice>("SDLRenderer");
|
sdlrenderer_selector_ = GetValidatedChild<wxChoice>("SDLRenderer");
|
||||||
sdlrenderer_selector_->SetValidator(SDLDevicesValidator());
|
sdlrenderer_selector_->SetValidator(SDLDevicesValidator());
|
||||||
|
|
||||||
|
#if !defined(ENABLE_SDL3) || !defined(HAVE_SDL3_PIXELART)
|
||||||
|
GetValidatedChild<wxCheckBox>("SDLPixelArt")->Hide();
|
||||||
|
#else
|
||||||
|
GetValidatedChild<wxCheckBox>("SDLPixelArt")
|
||||||
|
->SetValidator(
|
||||||
|
widgets::OptionBoolValidator(config::OptionID::kDispSDLPixelArt));
|
||||||
|
#endif
|
||||||
|
|
||||||
wxWindow* color_profile_srgb = GetValidatedChild("ColorProfileSRGB");
|
wxWindow* color_profile_srgb = GetValidatedChild("ColorProfileSRGB");
|
||||||
color_profile_srgb->SetValidator(
|
color_profile_srgb->SetValidator(
|
||||||
ColorCorrectionProfileValidator(config::ColorCorrectionProfile::kSRGB));
|
ColorCorrectionProfileValidator(config::ColorCorrectionProfile::kSRGB));
|
||||||
|
@@ -2577,7 +2577,11 @@ SDL_TEXTUREACCESS_STREAMING, (width * scale), (height * scale));
|
|||||||
|
|
||||||
// Set bilinear or nearest on the texture.
|
// Set bilinear or nearest on the texture.
|
||||||
#ifdef ENABLE_SDL3
|
#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);
|
SDL_SetTextureScaleMode(texture, OPTION(kDispBilinear) ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, OPTION(kDispBilinear) ? "1" : "0");
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, OPTION(kDispBilinear) ? "1" : "0");
|
||||||
#endif
|
#endif
|
||||||
|
@@ -170,6 +170,13 @@
|
|||||||
<flag>wxALL|wxEXPAND</flag>
|
<flag>wxALL|wxEXPAND</flag>
|
||||||
<border>5</border>
|
<border>5</border>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<object class="wxCheckBox" name="SDLPixelArt">
|
||||||
|
<label>SDL Pixel Art Filter</label>
|
||||||
|
</object>
|
||||||
|
<flag>wxALL|wxEXPAND</flag>
|
||||||
|
<border>5</border>
|
||||||
|
</object>
|
||||||
<cols>2</cols>
|
<cols>2</cols>
|
||||||
<growablecols>1</growablecols>
|
<growablecols>1</growablecols>
|
||||||
</object>
|
</object>
|
||||||
|
Reference in New Issue
Block a user