From 28a20218d29c1b7f1a49a22d7e3d7540f51d623a Mon Sep 17 00:00:00 2001 From: Luke Krasnoff Date: Sat, 20 Nov 2021 12:32:21 +1030 Subject: [PATCH] Fix BeginScissorMode for high DPI. Add comment to set FLAG_WINDOW_HIGHDPI flag. --- examples/core/core_scissor_test.c | 3 +++ src/rcore.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/core/core_scissor_test.c b/examples/core/core_scissor_test.c index 56eb84f80..278deec51 100644 --- a/examples/core/core_scissor_test.c +++ b/examples/core/core_scissor_test.c @@ -20,6 +20,9 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; + // If you have a high DPI screen you'll have to set the High DPI flag. + // SetConfigFlags(FLAG_WINDOW_HIGHDPI); + InitWindow(screenWidth, screenHeight, "raylib [core] example - scissor test"); Rectangle scissorArea = { 0, 0, 300, 300 }; diff --git a/src/rcore.c b/src/rcore.c index ec1601ca1..3b573a928 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2188,7 +2188,8 @@ void BeginScissorMode(int x, int y, int width, int height) { Vector2 scale = GetWindowScaleDPI(); - rlScissor((int)(x*scale.x), (int)(CORE.Window.currentFbo.height - (y + height)*scale.y), (int)(width*scale.x), (int)(height*scale.y)); + rlScissor((int)(x*scale.x), (int)(CORE.Window.currentFbo.height - y*scale.y - height/scale.y), + (int)(width*scale.x), (int)(height*scale.y)); } else {