From 40caf6163ff2e1274d71146c207fbde0c099b089 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 11 Apr 2012 21:14:59 +0200 Subject: menu/clipping_helper: made clipping working --- src/menu/clipping_helper.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/menu/clipping_helper.cpp') 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(box[0] + box[2], box[1] + box[3])); } - ClippingHelper::ClippingHelper(const Rectangle &rect) + ClippingHelper::ClippingHelper(const Container *parent, + const Rectangle &rect) { was_enabled = glIsEnabled(GL_SCISSOR_TEST); - // calculate intersection of old clipping and requested clipping Rectangle 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 -- cgit v1.2.3