Skip to content

Commit

Permalink
Fixed|GL: Setting scissor via runtime DGL API
Browse files Browse the repository at this point in the history
The game does not need to be aware of where the game widget is
located within the window.
  • Loading branch information
skyjake committed Jul 17, 2016
1 parent ea2e43c commit 44798b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions doomsday/apps/client/src/gl/dgl_common.cpp
Expand Up @@ -375,11 +375,16 @@ DENG_EXTERN_C void DGL_SetScissor(RectRaw const *rect)

GameWidget &game = ClientWindow::main().game();

GLState::current().setNormalizedScissor(
game.normalizedRect(
Rectanglei(rect->origin.x, rect->origin.y,
rect->size.width, rect->size.height),
game.rule().recti())).apply();
// Note that the game is unaware of the game widget position, assuming that (0,0)
// is the top left corner of the drawing area. Fortunately, the current viewport
// has been set to cover the game widget area, so we can set the scissor relative
// to it.

auto norm = GuiWidget::normalizedRect(Rectanglei(rect->origin.x, rect->origin.y,
rect->size.width, rect->size.height),
Rectanglei::fromSize(game.rule().recti().size()));

GLState::current().setNormalizedScissor(norm).apply();
}

#undef DGL_SetScissor2
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/gl/gl_draw.cpp
Expand Up @@ -409,7 +409,7 @@ DENG_EXTERN_C void GL_BeginBorderedProjection(dgl_borderedprojectionstate_t* bp)
int offset = int((bp->availWidth - bp->scaleFactor * bp->width) / 2 + .5f);
if(bp->flags & BPF_OVERDRAW_CLIP)
{
DGL_SetScissor2(DENG_GAMEVIEW_X + offset, DENG_GAMEVIEW_Y,
DGL_SetScissor2(offset, 0,
int(bp->scaleFactor * bp->width), bp->availHeight);
}

Expand All @@ -422,7 +422,7 @@ DENG_EXTERN_C void GL_BeginBorderedProjection(dgl_borderedprojectionstate_t* bp)
int offset = int((bp->availHeight - bp->scaleFactor * 1.2f * bp->height) / 2 + .5f);
if(bp->flags & BPF_OVERDRAW_CLIP)
{
DGL_SetScissor2(DENG_GAMEVIEW_X, DENG_GAMEVIEW_Y + offset,
DGL_SetScissor2(0, offset,
bp->availWidth, int(bp->scaleFactor * 1.2f * bp->height));
}

Expand Down

0 comments on commit 44798b7

Please sign in to comment.