aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/clipping_helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu/clipping_helper.cpp')
-rw-r--r--src/menu/clipping_helper.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/menu/clipping_helper.cpp b/src/menu/clipping_helper.cpp
index 3f6bc4cd..8b54d41b 100644
--- a/src/menu/clipping_helper.cpp
+++ b/src/menu/clipping_helper.cpp
@@ -37,26 +37,27 @@ namespace usdx
Point<int>(box[0] + box[2], box[1] + box[3]));
}
- ClippingHelper::ClippingHelper(const Rectangle<int> &rect)
+ ClippingHelper::ClippingHelper(const Container *parent,
+ const Rectangle<int> &rect)
{
was_enabled = glIsEnabled(GL_SCISSOR_TEST);
- // calculate intersection of old clipping and requested clipping
Rectangle<int> new_scissor_box(rect);
+ // calculate window coordinates of rectangle
+ if (parent) {
+ int offset = parent->get_size().get_height() - rect.get_bottom();
+ new_scissor_box.set_top(parent->get_window_coords().get_y() + offset);
+ }
+
+ // calculate intersection of old clipping and requested clipping
if (was_enabled) {
glGetIntegerv(GL_SCISSOR_BOX, scissor_box);
new_scissor_box = new_scissor_box.intersect(makeRect(scissor_box));
}
- log << log4cpp::Priority::DEBUG << "Clipping ("
- << new_scissor_box.get_width() << ", "
- << new_scissor_box.get_height() << ") at window offset: ("
- << new_scissor_box.get_top() << ", "
- << new_scissor_box.get_left() << ")";
-
// setup clipping box
- glScissor(new_scissor_box.get_top(), new_scissor_box.get_left(),
+ glScissor(new_scissor_box.get_left(), new_scissor_box.get_top(),
new_scissor_box.get_width(), new_scissor_box.get_height());
// enable clipping