fix clip_rect for window modes that reposition the UI

This commit is contained in:
2025-04-20 14:24:10 -05:00
parent d7c093fdeb
commit e30a5a6541

View File

@@ -254,14 +254,15 @@ void clip_rect(sf::RenderTarget& where, rectangle rect) {
store_clip_rects[p] = rect;
}
// TODO: Make sure this works for the scissor test...
setActiveRenderTarget(where);
auto viewport = where.getView().getViewport();
rectangle winRect(where);
location pivot = rect.bottomLeft();
pivot = where.mapCoordsToPixel(pivot);
location opposite = rect.topRight();
opposite = where.mapCoordsToPixel(opposite);
glEnable(GL_SCISSOR_TEST);
glScissor(pivot.x, rectangle(where).height() - pivot.y, rect.width() * viewport.width, rect.height() * viewport.height);
glScissor(pivot.x, rectangle(where).height() - pivot.y, abs(opposite.x - pivot.x), abs(opposite.y - pivot.y));
}
void clip_region(sf::RenderWindow& where, Region& region) {