Skip to content

Commit

Permalink
libgui|GLState: Normalized scissor
Browse files Browse the repository at this point in the history
The normalized scissor is relative to the viewport, so it can be used
with downscaled viewports.
  • Loading branch information
skyjake committed Jun 15, 2013
1 parent 3f1aae2 commit 8b36057
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/libgui/include/de/gui/glstate.h
Expand Up @@ -111,6 +111,7 @@ class LIBGUI_PUBLIC GLState
GLState &setViewport(Rectangleui const &viewportRect);
GLState &setScissor(Rectanglei const &scissorRect);
GLState &setScissor(Rectangleui const &scissorRect);
GLState &setNormalizedScissor(Rectanglef const &normScissorRect);
GLState &clearScissor();

gl::Cull cull() const;
Expand Down
10 changes: 10 additions & 0 deletions doomsday/libgui/src/glstate.cpp
Expand Up @@ -369,6 +369,16 @@ GLState &GLState::setScissor(Rectangleui const &scissorRect)
return *this;
}

GLState &GLState::setNormalizedScissor(Rectanglef const &normScissorRect)
{
Rectangleui vp = viewport();
Rectangleui scis(Vector2ui(normScissorRect.left() * vp.width(),
normScissorRect.top() * vp.height()),
Vector2ui(std::ceil(normScissorRect.right() * vp.width()),
std::ceil(normScissorRect.bottom() * vp.height())));
return setScissor(scis);
}

GLState &GLState::clearScissor()
{
d->props.set(Scissor, false);
Expand Down

0 comments on commit 8b36057

Please sign in to comment.