From f683abd2cd6b06de264bde5940572a0b22c89e12 Mon Sep 17 00:00:00 2001 From: Bruno de Lacheisserie Date: Sun, 12 May 2024 14:01:05 +0200 Subject: [PATCH] GLCanvasScissor : fix width calculation --- Common/Source/xcs/Screen/Custom/Point.hpp | 10 +++++++++- Common/Source/xcs/Screen/OpenGL/Scissor.hpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Common/Source/xcs/Screen/Custom/Point.hpp b/Common/Source/xcs/Screen/Custom/Point.hpp index 1cc76bc3ea..2ca9629f70 100644 --- a/Common/Source/xcs/Screen/Custom/Point.hpp +++ b/Common/Source/xcs/Screen/Custom/Point.hpp @@ -139,8 +139,16 @@ struct PixelRect { return { left, top }; } + constexpr PixelScalar GetWidth() const { + return right - left; + } + + constexpr PixelScalar GetHeight() const { + return bottom - top; + } + constexpr PixelSize GetSize() const { - return { right - left, bottom - top }; + return { GetWidth(), GetHeight() }; } constexpr RasterPoint GetCenter() const { diff --git a/Common/Source/xcs/Screen/OpenGL/Scissor.hpp b/Common/Source/xcs/Screen/OpenGL/Scissor.hpp index 0ea9ad1277..1a284704c5 100644 --- a/Common/Source/xcs/Screen/OpenGL/Scissor.hpp +++ b/Common/Source/xcs/Screen/OpenGL/Scissor.hpp @@ -50,7 +50,7 @@ class GLCanvasScissor : public GLEnable { private: void Scissor(PixelRect rc) { OpenGL::ToViewport(rc); - ::glScissor(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); + ::glScissor(rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); #if HAVE_GLES OpenGL::scissor_test = true; #endif @@ -69,7 +69,7 @@ class GLCanvasScissor : public GLScissor { explicit GLCanvasScissor(PixelRect rc) :GLScissor(OpenGL::translate.x + rc.left, OpenGL::viewport_size.y - OpenGL::translate.y - rc.bottom, - rc.right - rc.top, rc.bottom - rc.top) {} + rc.GetWidth(), rc.GetHeight()) {} }; #endif