diff --git a/mkxp.conf b/mkxp.conf index 6e81adc..c8a6a75 100644 --- a/mkxp.conf +++ b/mkxp.conf @@ -3,6 +3,7 @@ debugMode=true winResizable=true fullscreen=false fixedAspectRatio=false +smoothScaling=false vsync=true defScreenW=640 defScreenH=480 diff --git a/src/config.cpp b/src/config.cpp index eacb4e7..45d5934 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -33,6 +33,7 @@ Config::Config() winResizable(false), fullscreen(false), fixedAspectRatio(false), + smoothScaling(false), vsync(false), defScreenW(640), defScreenH(480), @@ -50,6 +51,7 @@ void Config::read() READ_VAL(winResizable, Bool); READ_VAL(fullscreen, Bool); READ_VAL(fixedAspectRatio, Bool); + READ_VAL(smoothScaling, Bool); READ_VAL(vsync, Bool); READ_VAL(defScreenW, Int); READ_VAL(defScreenH, Int); diff --git a/src/config.h b/src/config.h index d0e93bf..6d1492a 100644 --- a/src/config.h +++ b/src/config.h @@ -34,6 +34,7 @@ struct Config bool winResizable; bool fullscreen; bool fixedAspectRatio; + bool smoothScaling; bool vsync; int defScreenW; diff --git a/src/gl-util.h b/src/gl-util.h index ffd65e3..08839a1 100644 --- a/src/gl-util.h +++ b/src/gl-util.h @@ -147,6 +147,12 @@ namespace FBO Read = 1 }; + enum BlitMode + { + Nearest = 0, + Linear = 1 + }; + inline ID gen() { ID id; @@ -189,18 +195,26 @@ namespace FBO inline void blit(int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, - int dstW, int dstH) + int dstW, int dstH, + BlitMode mode = Nearest) { + static const GLenum modes[] = + { + GL_NEAREST, + GL_LINEAR + }; + glBlitFramebufferEXT(srcX, srcY, srcX+srcW, srcY+srcH, dstX, dstY, dstX+dstW, dstY+dstH, - GL_COLOR_BUFFER_BIT, GL_NEAREST); + GL_COLOR_BUFFER_BIT, modes[mode]); } inline void blit(int srcX, int srcY, int dstX, int dstY, - int srcW, int srcH) + int srcW, int srcH, + BlitMode mode = Nearest) { - blit(srcX, srcY, srcW, srcH, dstX, dstY, srcW, srcH); + blit(srcX, srcY, srcW, srcH, dstX, dstY, srcW, srcH, mode); } inline Vec4 getPixel(int x, int y) diff --git a/src/graphics.cpp b/src/graphics.cpp index 15ba8d9..eb50100 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -537,7 +537,7 @@ struct GraphicsPrivate { scSize = winSize; - if (!gState->config().fixedAspectRatio) + if (!threadData->config.fixedAspectRatio) { scOffset = Vec2i(0, 0); return; @@ -591,7 +591,8 @@ struct GraphicsPrivate void blitBufferFlippedScaled() { FBO::blit(0, 0, scRes.x, scRes.y, - scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y); + scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y, + threadData->config.smoothScaling ? FBO::Linear : FBO::Nearest); } /* Blits currently bound read FBO to screen (upside-down) */