From 1feb86ee97eaaaf326918d4945cdaa0a2f61d33f Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sat, 27 Jul 2019 14:40:50 +0100 Subject: BACKENDS: Handle screen shaking in WindowedGraphicsManager --- backends/graphics/gph/gph-graphics.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'backends/graphics/gph') diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index a55a8869bb..cb3e09ac49 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -78,6 +78,8 @@ ScalerProc *GPHGraphicsManager::getGraphicsScalerProc(int mode) const { void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); + _gameScreenShakeOffset = 0; + #ifdef USE_RGB_COLOR // Avoid redundant format changes Graphics::PixelFormat newFormat; @@ -216,16 +218,16 @@ void GPHGraphicsManager::internUpdateScreen() { #endif // If the shake position changed, fill the dirty area with blackness - if (_currentShakePos != _newShakePos || - (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { - SDL_Rect blackrect = {0, 0, _videoMode.screenWidth *_videoMode.scaleFactor, _newShakePos *_videoMode.scaleFactor}; + if (_currentShakePos != _gameScreenShakeOffset || + (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { + SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_gameScreenShakeOffset * _videoMode.scaleFactor)}; if (_videoMode.aspectRatioCorrection && !_overlayVisible) blackrect.h = real2Aspect(blackrect.h - 1) + 1; SDL_FillRect(_hwScreen, &blackrect, 0); - _currentShakePos = _newShakePos; + _currentShakePos = _gameScreenShakeOffset; _forceRedraw = true; } -- cgit v1.2.3