Browse Source

Add OptionEntry Scaling Quality

pull/3594/head
obligaron 4 years ago committed by Anders Jenbo
parent
commit
af4f732ef1
  1. 2
      Source/hwcursor.cpp
  2. 12
      Source/options.cpp
  3. 8
      Source/options.h
  4. 3
      Source/utils/display.cpp

2
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)

12
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<OptionEntryBase *> 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<OptionEntryBase *> GraphicsOptions::GetEntries()
{
return {};
return {
&scaleQuality,
};
}
GameplayOptions::GameplayOptions()

8
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<ScalingQuality> scaleQuality;
/** @brief Only scale by values divisible by the width and height. */
bool bIntegerScaling;
/** @brief Enable vsync on the output. */

3
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<int>(*sgOptions.Graphics.scaleQuality));
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, quality.c_str());
} else if (!gbForceWindowed && sgOptions.Graphics.bFullscreen) {
flags |= SDL_WINDOW_FULLSCREEN;
}

Loading…
Cancel
Save