diff --git a/Source/hwcursor.cpp b/Source/hwcursor.cpp index 3b43df191..556ae7d43 100644 --- a/Source/hwcursor.cpp +++ b/Source/hwcursor.cpp @@ -64,7 +64,7 @@ Point GetHotpointPosition(const SDL_Surface &surface, HotpointPosition position) bool ShouldUseBilinearScaling() { - return sgOptions.Graphics.szScaleQuality[0] != '0'; + return *sgOptions.Graphics.scaleQuality != ScalingQuality::NearestPixel; } bool SetHardwareCursor(SDL_Surface *surface, HotpointPosition hotpointPosition) diff --git a/Source/options.cpp b/Source/options.cpp index c94588a7c..c3c926db2 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -251,7 +251,6 @@ void LoadOptions() sgOptions.Graphics.bUpscale = false; #endif sgOptions.Graphics.bFitToScreen = GetIniBool("Graphics", "Fit to Screen", true); - GetIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality, sizeof(sgOptions.Graphics.szScaleQuality), "2"); sgOptions.Graphics.bIntegerScaling = GetIniBool("Graphics", "Integer Scaling", false); sgOptions.Graphics.bVSync = GetIniBool("Graphics", "Vertical Sync", true); sgOptions.Graphics.bBlendedTransparancy = GetIniBool("Graphics", "Blended Transparency", true); @@ -407,7 +406,6 @@ void SaveOptions() SetIniValue("Graphics", "Upscale", sgOptions.Graphics.bUpscale); #endif SetIniValue("Graphics", "Fit to Screen", sgOptions.Graphics.bFitToScreen); - SetIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality); SetIniValue("Graphics", "Integer Scaling", sgOptions.Graphics.bIntegerScaling); SetIniValue("Graphics", "Vertical Sync", sgOptions.Graphics.bVSync); SetIniValue("Graphics", "Blended Transparency", sgOptions.Graphics.bBlendedTransparancy); @@ -615,11 +613,19 @@ std::vector AudioOptions::GetEntries() GraphicsOptions::GraphicsOptions() : OptionCategoryBase("Graphics", N_("Graphics"), N_("Graphics Settings")) + , scaleQuality("Scaling Quality", OptionEntryFlags::None, N_("Scaling Quality"), N_("Enables optional filters to the output image when upscaling."), ScalingQuality::AnisotropicFiltering, + { + { ScalingQuality::NearestPixel, N_("Nearest Pixel") }, + { ScalingQuality::BilinearFiltering, N_("Bilinear") }, + { ScalingQuality::AnisotropicFiltering, N_("Anisotropic") }, + }) { } std::vector GraphicsOptions::GetEntries() { - return {}; + return { + &scaleQuality, + }; } GameplayOptions::GameplayOptions() diff --git a/Source/options.h b/Source/options.h index 467b836d4..d39900f47 100644 --- a/Source/options.h +++ b/Source/options.h @@ -16,6 +16,12 @@ enum class StartUpGameOption { Diablo, }; +enum class ScalingQuality { + NearestPixel, + BilinearFiltering, + AnisotropicFiltering, +}; + enum class OptionEntryType { Boolean, List, @@ -234,7 +240,7 @@ struct GraphicsOptions : OptionCategoryBase { /** @brief Expand the aspect ratio to match the screen. */ bool bFitToScreen; /** @brief See SDL_HINT_RENDER_SCALE_QUALITY. */ - char szScaleQuality[2]; + OptionEntryEnum scaleQuality; /** @brief Only scale by values divisible by the width and height. */ bool bIntegerScaling; /** @brief Enable vsync on the output. */ diff --git a/Source/utils/display.cpp b/Source/utils/display.cpp index 3fcbf31c8..0466eb872 100644 --- a/Source/utils/display.cpp +++ b/Source/utils/display.cpp @@ -207,7 +207,8 @@ bool SpawnWindow(const char *lpWindowName) } flags |= SDL_WINDOW_RESIZABLE; - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sgOptions.Graphics.szScaleQuality); + auto quality = fmt::format("{}", static_cast(*sgOptions.Graphics.scaleQuality)); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, quality.c_str()); } else if (!gbForceWindowed && sgOptions.Graphics.bFullscreen) { flags |= SDL_WINDOW_FULLSCREEN; }