mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-21 00:51:12 +00:00
Fix canvas textures getting clipped by wrong scissor box
This commit is contained in:
parent
1a1adc5c29
commit
181eda0a83
3 changed files with 10 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -147,6 +147,8 @@ public:
|
|||
BoneBuffer* mBones = nullptr; // Model bones
|
||||
IShadowMap mShadowMap;
|
||||
|
||||
int mGameScreenWidth = 0;
|
||||
int mGameScreenHeight = 0;
|
||||
IntRect mScreenViewport;
|
||||
IntRect mSceneViewport;
|
||||
IntRect mOutputLetterbox;
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue