From ca85e3d8e901a91b2af9fc22c8dc8084ca2b6680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Ko=C5=82odziejski?= Date: Sun, 13 Oct 2024 12:03:24 +0200 Subject: [PATCH] WINTERMUTE: Restore getProjectionParams from original code --- .../wintermute/base/gfx/base_renderer3d.cpp | 29 +++++++++++++++++++ engines/wintermute/base/gfx/base_renderer3d.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/engines/wintermute/base/gfx/base_renderer3d.cpp b/engines/wintermute/base/gfx/base_renderer3d.cpp index f0d0e96a3b6..4e6379a158a 100644 --- a/engines/wintermute/base/gfx/base_renderer3d.cpp +++ b/engines/wintermute/base/gfx/base_renderer3d.cpp @@ -57,6 +57,35 @@ bool BaseRenderer3D::drawSprite(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect return drawSpriteEx(tex, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY); } +bool BaseRenderer3D::getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight, + float *modWidth, float *modHeight, bool *customViewport) { + *resWidth = _width; + *resHeight = _height; + + int lWidth, lHeight; + Rect32 sceneViewport; + _gameRef->getLayerSize(&lWidth, &lHeight, &sceneViewport, customViewport); + *layerWidth = (float)lWidth; + *layerHeight = (float)lHeight; + + *modWidth = 0.0f; + *modHeight = 0.0f; + if (*layerWidth > *resWidth) + *modWidth = (*layerWidth - *resWidth) / 2.0f; + if (*layerHeight > *resHeight) + *modHeight = (*layerHeight - *resHeight) / 2.0f; + + // new in 1.7.2.1 + // if layer height is smaller than resolution, we assume that we don't want to scroll + // and that the camera overviews the entire resolution + if (*layerHeight < *resHeight) { + *modHeight -= (*resHeight - *layerHeight) / 2; + *layerHeight = *resHeight; + } + + return true; +} + void BaseRenderer3D::project(const Math::Matrix4 &worldMatrix, const Math::Vector3d &point, int32 &x, int32 &y) { Math::Matrix4 tmp = worldMatrix; tmp.transpose(); diff --git a/engines/wintermute/base/gfx/base_renderer3d.h b/engines/wintermute/base/gfx/base_renderer3d.h index ef57f984eba..baee2675179 100644 --- a/engines/wintermute/base/gfx/base_renderer3d.h +++ b/engines/wintermute/base/gfx/base_renderer3d.h @@ -59,6 +59,8 @@ public: BaseRenderer3D(BaseGame *inGame = nullptr); ~BaseRenderer3D() override; + bool getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight, + float *modWidth, float *modHeight, bool *customViewport); bool setAmbientLightColor(uint32 color); bool setDefaultAmbientLightColor(); virtual void setAmbientLight() = 0;