From b8390fa161c0c324af0e52a4f3a740cca9e9a479 Mon Sep 17 00:00:00 2001 From: sluicebox Date: Fri, 15 Nov 2019 01:38:21 -0800 Subject: GRAPHICS: Add interface for horizontal shake --- backends/platform/ios7/ios7_common.h | 6 ++++-- backends/platform/ios7/ios7_osys_main.h | 2 +- backends/platform/ios7/ios7_osys_video.mm | 10 ++++++---- backends/platform/ios7/ios7_video.h | 3 ++- backends/platform/ios7/ios7_video.mm | 11 ++++++----- 5 files changed, 19 insertions(+), 13 deletions(-) (limited to 'backends/platform/ios7') diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h index aa5134335e..dd1e85a884 100644 --- a/backends/platform/ios7/ios7_common.h +++ b/backends/platform/ios7/ios7_common.h @@ -80,7 +80,8 @@ struct VideoContext { VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false), overlayWidth(), overlayHeight(), mouseX(), mouseY(), mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), - mouseIsVisible(), graphicsMode(kGraphicsModeNone), filtering(false), shakeOffsetY() { + mouseIsVisible(), graphicsMode(kGraphicsModeNone), filtering(false), + shakeXOffset(), shakeYOffset() { } // Game screen state @@ -103,7 +104,8 @@ struct VideoContext { // Misc state GraphicsModes graphicsMode; bool filtering; - int shakeOffsetY; + int shakeXOffset; + int shakeYOffset; }; struct InternalEvent { diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h index 994a67dddb..f70e48e7de 100644 --- a/backends/platform/ios7/ios7_osys_main.h +++ b/backends/platform/ios7/ios7_osys_main.h @@ -161,7 +161,7 @@ public: virtual void updateScreen(); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); - virtual void setShakePos(int shakeOffset); + virtual void setShakePos(int shakeXOffset, int shakeYOffset); virtual void showOverlay(); virtual void hideOverlay(); diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm index 20cf687709..d31ca10ea3 100644 --- a/backends/platform/ios7/ios7_osys_video.mm +++ b/backends/platform/ios7/ios7_osys_video.mm @@ -138,7 +138,8 @@ void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat _videoContext->screenWidth = width; _videoContext->screenHeight = height; - _videoContext->shakeOffsetY = 0; + _videoContext->shakeXOffset = 0; + _videoContext->shakeYOffset = 0; // In case we use the screen texture as frame buffer we reset the pixels // pointer here to avoid freeing the screen texture. @@ -354,9 +355,10 @@ void OSystem_iOS7::unlockScreen() { dirtyFullScreen(); } -void OSystem_iOS7::setShakePos(int shakeOffset) { - //printf("setShakePos(%i)\n", shakeOffset); - _videoContext->shakeOffsetY = shakeOffset; +void OSystem_iOS7::setShakePos(int shakeXOffset, int shakeYOffset) { + //printf("setShakePos(%i, %i)\n", shakeXOffset, shakeYOffset); + _videoContext->shakeXOffset = shakeXOffset; + _videoContext->shakeYOffset = shakeYOffset; execute_on_main_thread(^ { [[iOS7AppDelegate iPhoneView] setViewTransformation]; }); diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h index a26213f28e..030d81cd9f 100644 --- a/backends/platform/ios7/ios7_video.h +++ b/backends/platform/ios7/ios7_video.h @@ -84,7 +84,8 @@ typedef struct { GLint _mouseWidth, _mouseHeight; GLfloat _mouseScaleX, _mouseScaleY; - int _scaledShakeOffsetY; + int _scaledShakeXOffset; + int _scaledShakeYOffset; UITouch *_firstTouch; UITouch *_secondTouch; diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm index 321ccdb63d..914dc6ded1 100644 --- a/backends/platform/ios7/ios7_video.mm +++ b/backends/platform/ios7/ios7_video.mm @@ -454,7 +454,8 @@ uint getSizeNextPOT(uint size) { _overlayTexture = 0; _mouseCursorTexture = 0; - _scaledShakeOffsetY = 0; + _scaledShakeXOffset = 0; + _scaledShakeYOffset = 0; _firstTouch = NULL; _secondTouch = NULL; @@ -868,9 +869,9 @@ uint getSizeNextPOT(uint size) { - (void)setViewTransformation { // Scale the shake offset according to the overlay size. We need this to // adjust the overlay mouse click coordinates when an offset is set. - _scaledShakeOffsetY = (int)(_videoContext.shakeOffsetY / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect)); + _scaledShakeYOffset = (int)(_videoContext.shakeYOffset / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect)); - glUniform1f(_shakeSlot, _scaledShakeOffsetY); + glUniform1f(_shakeSlot, _scaledShakeYOffset); } - (void)clearColorBuffer { @@ -914,12 +915,12 @@ uint getSizeNextPOT(uint size) { area = &_overlayRect; width = _videoContext.overlayWidth; height = _videoContext.overlayHeight; - offsetY = _scaledShakeOffsetY; + offsetY = _scaledShakeYOffset; } else { area = &_gameScreenRect; width = _videoContext.screenWidth; height = _videoContext.screenHeight; - offsetY = _videoContext.shakeOffsetY; + offsetY = _videoContext.shakeYOffset; } point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); -- cgit v1.2.3