diff --git a/binding/graphics-binding.cpp b/binding/graphics-binding.cpp index 6873f35..d28521f 100644 --- a/binding/graphics-binding.cpp +++ b/binding/graphics-binding.cpp @@ -368,7 +368,7 @@ DEF_GRA_PROP_B(ShowCursor) DEF_GRA_PROP_F(Scale) DEF_GRA_PROP_B(Frameskip) DEF_GRA_PROP_B(FixedAspectRatio) -DEF_GRA_PROP_B(SmoothScaling) +DEF_GRA_PROP_I(SmoothScaling) DEF_GRA_PROP_B(IntegerScaling) DEF_GRA_PROP_B(LastMileScaling) DEF_GRA_PROP_B(Threadsafe) diff --git a/mkxp.json b/mkxp.json index 8188604..f1f06f3 100644 --- a/mkxp.json +++ b/mkxp.json @@ -77,18 +77,15 @@ // "fixedAspectRatio": true, - // Apply linear interpolation when game screen + // Apply smooth interpolation when game screen // is upscaled - // (default: disabled) + // 0: Nearest-Neighbor + // 1: Bilinear + // 2: (Reserved) + // 3: Lanczos3 + // (default: 0) // - // "smoothScaling": false, - - - // Apply Lanczos3 interpolation when game screen - // is upscaled (typically higher quality than linear) - // (default: disabled) - // - // "lanczos3Scaling": false, + // "smoothScaling": 0, // Replace the game's Bitmap files with external high-res files diff --git a/src/config.cpp b/src/config.cpp index ca786af..7e40083 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -134,8 +134,7 @@ void Config::read(int argc, char *argv[]) { {"winResizable", true}, {"fullscreen", false}, {"fixedAspectRatio", true}, - {"smoothScaling", false}, - {"lanczos3Scaling", false}, + {"smoothScaling", 0}, {"enableHires", false}, {"textureScalingFactor", 1.}, {"framebufferScalingFactor", 1.}, @@ -263,8 +262,7 @@ try { exp } catch (...) {} SET_OPT(printFPS, boolean); SET_OPT(fullscreen, boolean); SET_OPT(fixedAspectRatio, boolean); - SET_OPT(smoothScaling, boolean); - SET_OPT(lanczos3Scaling, boolean); + SET_OPT(smoothScaling, integer); SET_OPT(enableHires, boolean); SET_OPT(textureScalingFactor, number); SET_OPT(framebufferScalingFactor, number); diff --git a/src/config.h b/src/config.h index 328df34..bd253f7 100644 --- a/src/config.h +++ b/src/config.h @@ -43,8 +43,7 @@ struct Config { bool winResizable; bool fullscreen; bool fixedAspectRatio; - bool smoothScaling; - bool lanczos3Scaling; + int smoothScaling; bool enableHires; double textureScalingFactor; double framebufferScalingFactor; diff --git a/src/display/gl/gl-meta.cpp b/src/display/gl/gl-meta.cpp index f80050c..ded309a 100644 --- a/src/display/gl/gl-meta.cpp +++ b/src/display/gl/gl-meta.cpp @@ -25,6 +25,7 @@ #include "glstate.h" #include "quad.h" #include "config.h" +#include "etc.h" namespace FBO { @@ -151,7 +152,9 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size) FBO::bind(fbo); glState.viewport.pushSet(IntRect(0, 0, size.x, size.y)); - if (shState->config().lanczos3Scaling) + switch (shState->config().smoothScaling) + { + case Lanczos3: { Lanczos3Shader &shader = shState->shaders().lanczos3; shader.bind(); @@ -159,7 +162,9 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size) shader.setTranslation(Vec2i()); shader.setTexSize(Vec2i(size.x, size.y)); } - else + + break; + default: { SimpleShader &shader = shState->shaders().simple; shader.bind(); @@ -167,6 +172,7 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size) shader.setTranslation(Vec2i()); shader.setTexSize(Vec2i(size.x, size.y)); } + } } } @@ -226,18 +232,23 @@ void blitSource(TEXFBO &source) } else { - if (shState->config().lanczos3Scaling) + switch (shState->config().smoothScaling) + { + case Lanczos3: { Lanczos3Shader &shader = shState->shaders().lanczos3; shader.bind(); shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires)); } - else + + break; + default: { SimpleShader &shader = shState->shaders().simple; shader.bind(); shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires)); } + } if (source.selfHires != nullptr) { TEX::bind(source.selfHires->tex); } diff --git a/src/display/graphics.cpp b/src/display/graphics.cpp index 2a9fe93..348a713 100644 --- a/src/display/graphics.cpp +++ b/src/display/graphics.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "debugwriter.h" #include "disposable.h" +#include "etc.h" #include "etc-internal.h" #include "eventthread.h" #include "filesystem.h" @@ -1020,13 +1021,13 @@ struct GraphicsPrivate { (scSize.y + scOffset.y), scSize.x, -scSize.y), - threadData->config.smoothScaling); + threadData->config.smoothScaling == Bilinear); } void metaBlitBufferFlippedScaled(const Vec2i &sourceSize, bool forceNearestNeighbor=false) { GLMeta::blitRectangle(IntRect(0, 0, sourceSize.x, sourceSize.y), IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y), - !forceNearestNeighbor && threadData->config.smoothScaling); + !forceNearestNeighbor && threadData->config.smoothScaling == Bilinear); } void redrawScreen() { @@ -1613,13 +1614,13 @@ void Graphics::setFixedAspectRatio(bool value) p->updateScreenResoRatio(p->threadData); } -bool Graphics::getSmoothScaling() const +int Graphics::getSmoothScaling() const { // Same deal as with fixed aspect ratio return shState->config().smoothScaling; } -void Graphics::setSmoothScaling(bool value) +void Graphics::setSmoothScaling(int value) { shState->config().smoothScaling = value; } diff --git a/src/display/graphics.h b/src/display/graphics.h index 130478f..ac5ab55 100644 --- a/src/display/graphics.h +++ b/src/display/graphics.h @@ -81,7 +81,7 @@ public: DECL_ATTR( Scale, double ) DECL_ATTR( Frameskip, bool ) DECL_ATTR( FixedAspectRatio, bool ) - DECL_ATTR( SmoothScaling, bool ) + DECL_ATTR( SmoothScaling, int ) DECL_ATTR( IntegerScaling, bool ) DECL_ATTR( LastMileScaling, bool ) DECL_ATTR( Threadsafe, bool ) diff --git a/src/etc/etc.h b/src/etc/etc.h index f9033e2..a7e7986 100644 --- a/src/etc/etc.h +++ b/src/etc/etc.h @@ -200,6 +200,14 @@ struct Rect : public Serializable sigslot::signal<> valueChanged; }; +enum InterpolationMethod +{ + NearestNeighbor = 0, + Bilinear = 1, + // Reserving 2 for Bicubic + Lanczos3 = 3, +}; + /* For internal use. * All drawable classes have properties of one or more of the above * types, which in an interpreted environment act as independent