diff --git a/src/common/rendering/v_framebuffer.cpp b/src/common/rendering/v_framebuffer.cpp index c0ebb4c25d..271348bc16 100644 --- a/src/common/rendering/v_framebuffer.cpp +++ b/src/common/rendering/v_framebuffer.cpp @@ -170,6 +170,8 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) mSceneViewport = *bounds; mScreenViewport = *bounds; mOutputLetterbox = *bounds; + mGameScreenWidth = mScreenViewport.width; + mGameScreenHeight = mScreenViewport.height; return; } @@ -216,6 +218,9 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) mSceneViewport.width = (int)round(mSceneViewport.width * scaleX); mSceneViewport.height = (int)round(mSceneViewport.height * scaleY); } + + mGameScreenWidth = GetWidth(); + mGameScreenHeight = GetHeight(); } //=========================================================================== @@ -226,12 +231,12 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) int DFrameBuffer::ScreenToWindowX(int x) { - return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)GetWidth()); + return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)mGameScreenWidth); } int DFrameBuffer::ScreenToWindowY(int y) { - return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)GetHeight()); + return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)mGameScreenHeight); } void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y) diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index 3be892efe7..afba5784ae 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -147,6 +147,8 @@ public: BoneBuffer* mBones = nullptr; // Model bones IShadowMap mShadowMap; + int mGameScreenWidth = 0; + int mGameScreenHeight = 0; IntRect mScreenViewport; IntRect mSceneViewport; IntRect mOutputLetterbox; diff --git a/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index da63685830..42106f472f 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -360,6 +360,7 @@ sector_t* RenderView(player_t* player) { screen->RenderTextureView(canvas->Tex, [=](IntRect& bounds) { + screen->SetViewportRects(&bounds); Draw2D(&canvas->Drawer, *screen->RenderState(), 0, 0, canvas->Tex->GetWidth(), canvas->Tex->GetHeight()); canvas->Drawer.Clear(); });