diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-04-11 21:14:59 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-13 22:40:52 +0100 |
commit | 40caf6163ff2e1274d71146c207fbde0c099b089 (patch) | |
tree | 200d52aa09aa03cd199216d8ad172a57dcde62e0 /src/menu/clipping_helper.cpp | |
parent | bb8e600a93557207410cf11977d19bb5bc133fcc (diff) | |
download | usdx-40caf6163ff2e1274d71146c207fbde0c099b089.tar.gz usdx-40caf6163ff2e1274d71146c207fbde0c099b089.tar.xz usdx-40caf6163ff2e1274d71146c207fbde0c099b089.zip |
menu/clipping_helper: made clipping working
Diffstat (limited to '')
-rw-r--r-- | src/menu/clipping_helper.cpp | 19 |
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 |