[Scummvm-tracker] [ScummVM :: Bugs] #14061: OPENGL: Vertical position of cursor during screen shake appears to be miscalculated

ScummVM :: Bugs trac at scummvm.org
Mon Jan 23 10:37:55 UTC 2023


#14061: OPENGL: Vertical position of cursor during screen shake appears to be
miscalculated
--------------------------------+----------------------------------
Reporter:  AndywinXp            |       Owner:  (none)
    Type:  defect               |      Status:  new
Priority:  high                 |   Component:  Graphics
 Version:                       |  Resolution:
Keywords:  cursor screen shake  |        Game:  Day of the Tentacle
--------------------------------+----------------------------------
Description changed by AndywinXp:

Old description:

> **How to reproduce:**
>
> Start up Day Of The Tentacle, go to Green Tentacle's room and turn on the
> stereo. The screen should begin shaking.
>
> **What should happen:**
>
> The cursor should stay visible during the screen effect.
>
> **What happens instead:**
>
> During the screen shake effect, whenever the screen position is different
> from the origin one (0, 0), the cursor coordinates get recalculated to
> send the cursor texture elsewhere (out of bounds), effectively making the
> cursor invisible during the shake frames, producing a flicker effect.
>
> ----
>
> This seems to be a regression produced by this commit and apparently it
> only affects the OpenGL backend:
> https://github.com/scummvm/scummvm/commit/87bad2cc7d602488ba3fbdf8ff067d3d74fc2b85
>
> In particular, in the following function:
>
> {{{
> void OpenGLGraphicsManager::recalculateDisplayAreas()
> }}}
>

> the responsible line for the offset recalculation seems to be the
> following:
>
> {{{
> _shakeOffsetScaled = Common::Point(
>     _gameScreenShakeXOffset * _gameDrawRect.width() /
> _currentState.gameWidth,
>     _gameScreenShakeYOffset * _gameDrawRect.height() /
> _currentState.gameHeight
> );
> }}}
>
> in which `_shakeOffsetScaled` is calculated. The result of this
> calculation will then be used in `OpenGLGraphicsManager::updateScreen()`
> to calculate the position of the cursor texture:
>
> {{{
> _pipeline->drawTexture(_cursor->getGLTexture(),
>     _cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
>     _cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,
>     _cursorWidthScaled, _cursorHeightScaled
> );
> }}}
>
> When debugging the issue I noticed that (for the case at hand, DOTT,
> which shakes the screen vertically only), the `y` component of
> `_shakeOffsetScaled` contained garbage values (e.g. -20990) when the
> screen Y offset was not zero.
>
> Just for the sake of it, when calculating `_shakeOffsetScaled` I tried
> substituting `_gameScreenShakeYOffset` with `1`, and the cursor worked
> properly. Of course that's not the correct solution to the issue, but I
> hope that this can be helpful for resolving it.
>
> I'll attach a DOTT savegame for that particular scene, in which the
> screen is already shaking.

New description:

 **How to reproduce:**

 Start up Day Of The Tentacle, go to Green Tentacle's room and turn on the
 stereo. The screen should begin shaking. Or just load the savegame I
 attached :-)

 **What should happen:**

 The cursor should stay visible during the screen effect.

 **What happens instead:**

 During the screen shake effect, whenever the screen position is different
 from the origin one (0, 0), the cursor coordinates get recalculated to
 send the cursor texture elsewhere (out of bounds), effectively making the
 cursor invisible during the shake frames, producing a flicker effect.

 ----

 This seems to be a regression produced by this commit and apparently it
 only affects the OpenGL backend:
 https://github.com/scummvm/scummvm/commit/87bad2cc7d602488ba3fbdf8ff067d3d74fc2b85

 In particular, in the following function:

 {{{
 void OpenGLGraphicsManager::recalculateDisplayAreas()
 }}}


 the responsible line for the offset recalculation seems to be the
 following:

 {{{
 _shakeOffsetScaled = Common::Point(
     _gameScreenShakeXOffset * _gameDrawRect.width() /
 _currentState.gameWidth,
     _gameScreenShakeYOffset * _gameDrawRect.height() /
 _currentState.gameHeight
 );
 }}}

 in which `_shakeOffsetScaled` is calculated. The result of this
 calculation will then be used in `OpenGLGraphicsManager::updateScreen()`
 to calculate the position of the cursor texture:

 {{{
 _pipeline->drawTexture(_cursor->getGLTexture(),
     _cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
     _cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,
     _cursorWidthScaled, _cursorHeightScaled
 );
 }}}

 When debugging the issue I noticed that (for the case at hand, DOTT, which
 shakes the screen vertically only), the `y` component of
 `_shakeOffsetScaled` contained garbage values (e.g. -20990) when the
 screen Y offset was not zero.

 Just for the sake of it, when calculating `_shakeOffsetScaled` I tried
 substituting `_gameScreenShakeYOffset` with `1`, and the cursor worked
 properly. Of course that's not the correct solution to the issue, but I
 hope that this can be helpful for resolving it.

 I'll attach a DOTT savegame for that particular scene, in which the screen
 is already shaking.

--
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/14061#comment:1>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list