[Scummvm-git-logs] scummvm branch-2-7 -> 6031cca314a7a941045b290f4410667c30a779e5
lephilousophe
noreply at scummvm.org
Sun Feb 5 19:54:02 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6031cca314 BACKENDS: OPENGL: Use a floating point cursor size
Commit: 6031cca314a7a941045b290f4410667c30a779e5
https://github.com/scummvm/scummvm/commit/6031cca314a7a941045b290f4410667c30a779e5
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-02-05T20:53:45+01:00
Commit Message:
BACKENDS: OPENGL: Use a floating point cursor size
When scaler shaders are used, cursor size is adapted to scale on the
game screen texture and not on the back buffer so the size is scaled
twice and is imprecise.
Using a float gives more precision without any performance impact as the
OpenGL code already expects floats.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 15c536b7fb7..19078c46e76 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -667,9 +667,9 @@ void OpenGLGraphicsManager::updateScreen() {
_backBuffer.enableBlend(Framebuffer::kBlendModePremultipliedTransparency);
_pipeline->drawTexture(_cursor->getGLTexture(),
- _cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
- _cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,
- _cursorWidthScaled, _cursorHeightScaled);
+ _cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
+ _cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,
+ _cursorWidthScaled, _cursorHeightScaled);
drawCursor = false;
// Everything we need to clip has been clipped
@@ -1518,11 +1518,14 @@ void OpenGLGraphicsManager::recalculateCursorScaling() {
return;
}
+ uint cursorWidth = _cursor->getWidth();
+ uint cursorHeight = _cursor->getHeight();
+
// By default we use the unscaled versions.
_cursorHotspotXScaled = _cursorHotspotX;
_cursorHotspotYScaled = _cursorHotspotY;
- _cursorWidthScaled = _cursor->getWidth();
- _cursorHeightScaled = _cursor->getHeight();
+ _cursorWidthScaled = cursorWidth;
+ _cursorHeightScaled = cursorHeight;
// In case scaling is actually enabled we will scale the cursor according
// to the game screen.
@@ -1531,10 +1534,10 @@ void OpenGLGraphicsManager::recalculateCursorScaling() {
const frac_t screenScaleFactorY = intToFrac(_gameDrawRect.height()) / _gameScreen->getHeight();
_cursorHotspotXScaled = fracToInt(_cursorHotspotXScaled * screenScaleFactorX);
- _cursorWidthScaled = fracToInt(_cursorWidthScaled * screenScaleFactorX);
+ _cursorWidthScaled = fracToDouble(cursorWidth * screenScaleFactorX);
_cursorHotspotYScaled = fracToInt(_cursorHotspotYScaled * screenScaleFactorY);
- _cursorHeightScaled = fracToInt(_cursorHeightScaled * screenScaleFactorY);
+ _cursorHeightScaled = fracToDouble(cursorHeight * screenScaleFactorY);
}
}
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 3b27c6e33cf..4cd3c1f45f7 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -405,12 +405,12 @@ protected:
/**
* The width of the cursor in scaled game display area coordinates.
*/
- uint _cursorWidthScaled;
+ float _cursorWidthScaled;
/**
* The height of the cursor in scaled game display area coordinates.
*/
- uint _cursorHeightScaled;
+ float _cursorHeightScaled;
/**
* The key color.
More information about the Scummvm-git-logs
mailing list