Skip to content

Commit

Permalink
GLCanvasScissor : fix width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotl committed May 12, 2024
1 parent 492e315 commit f683abd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Common/Source/xcs/Screen/Custom/Point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Common/Source/xcs/Screen/OpenGL/Scissor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GLCanvasScissor : public GLEnable<GL_SCISSOR_TEST> {
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
Expand All @@ -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
Expand Down

0 comments on commit f683abd

Please sign in to comment.