aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2015-12-14 20:09:29 +0100
committerJohannes Schickel2015-12-14 20:26:05 +0100
commit64f9c902ddf0c8294fd9e5f66cf96661eb12040b (patch)
treed4694c5bc2a64ec9e886c0973a92454cc54a45f0 /backends/graphics
parent8dd9d44b1ff4bd531f7668973206be2fb372fdde (diff)
downloadscummvm-rg350-64f9c902ddf0c8294fd9e5f66cf96661eb12040b.tar.gz
scummvm-rg350-64f9c902ddf0c8294fd9e5f66cf96661eb12040b.tar.bz2
scummvm-rg350-64f9c902ddf0c8294fd9e5f66cf96661eb12040b.zip
OPENGL: Smooth mouse experience when black bars are visible.
This gets rid of the feeling of the mouse sticking to black borders by using the full output resolution as area for tracking game mouse movement. The same behavior is present in plain SDL output with SDL2.
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index c80f57a40e..ac6d41d47d 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -551,11 +551,8 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) {
return;
}
- x = (x * _displayWidth) / _gameScreen->getWidth();
- y = (y * _displayHeight) / _gameScreen->getHeight();
-
- x += _displayX;
- y += _displayY;
+ x = (x * _outputScreenWidth) / _gameScreen->getWidth();
+ y = (y * _outputScreenHeight) / _gameScreen->getHeight();
}
setMousePosition(x, y);
@@ -946,18 +943,11 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
y = (y * _overlay->getHeight()) / _outputScreenHeight;
}
} else if (_gameScreen) {
- x -= _displayX;
- y -= _displayY;
-
const int16 width = _gameScreen->getWidth();
const int16 height = _gameScreen->getHeight();
- x = (x * width) / (int)_displayWidth;
- y = (y * height) / (int)_displayHeight;
-
- // Make sure we only supply valid coordinates.
- x = CLIP<int16>(x, 0, width - 1);
- y = CLIP<int16>(y, 0, height - 1);
+ x = (x * width) / (int)_outputScreenWidth;
+ y = (y * height) / (int)_outputScreenHeight;
}
}
@@ -975,8 +965,8 @@ void OpenGLGraphicsManager::setMousePosition(int x, int y) {
_cursorDisplayX = x;
_cursorDisplayY = y;
} else {
- _cursorDisplayX = CLIP<int>(x, _displayX, _displayX + _displayWidth - 1);
- _cursorDisplayY = CLIP<int>(y, _displayY, _displayY + _displayHeight - 1);
+ _cursorDisplayX = _displayX + (x * _displayWidth) / _outputScreenWidth;
+ _cursorDisplayY = _displayY + (y * _displayHeight) / _outputScreenHeight;
}
}