Skip to content

Commit

Permalink
UI|Client: Draw the game HUD layer in ViewCompositor
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 28, 2016
1 parent eab1beb commit 1a52664
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/ui/viewcompositor.h
Expand Up @@ -78,7 +78,7 @@ class ViewCompositor
*
* @param rect Rectangle in which to draw the layers.
*/
void drawCompositedLayers(de::Rectanglei const &rect);
void drawCompositedLayers();

private:
DENG2_PRIVATE(d)
Expand Down
66 changes: 57 additions & 9 deletions doomsday/apps/client/src/ui/viewcompositor.cpp
Expand Up @@ -157,7 +157,7 @@ GLTextureFramebuffer const &ViewCompositor::gameView() const
return d->viewFramebuf;
}

void ViewCompositor::drawCompositedLayers(Rectanglei const &rect)
void ViewCompositor::drawCompositedLayers()
{
DENG2_ASSERT(d->frameDrawable.isReady());

Expand All @@ -168,31 +168,79 @@ void ViewCompositor::drawCompositedLayers(Rectanglei const &rect)
.setCull (gl::None);

Rectanglei const view3D = R_Console3DViewRect(d->playerNum);

// First the game view (using the previously rendered texture).
d->uFrameTex = d->viewFramebuf.colorTexture();
d->uMvpMatrix = ClientWindow::main().root().projMatrix2D() *
Matrix4f::scaleThenTranslate(view3D.size(), view3D.topLeft);
d->frameDrawable.draw();
auto const oldDisplayPlayer = displayPlayer;

// View border around the game view.
auto const oldDisplayPlayer = displayPlayer;
displayPlayer = d->playerNum;

R_UseViewPort(d->playerNum);

//R_RenderPlayerViewBorder();
// 3D world view (using the previously rendered texture).
{
d->uFrameTex = d->viewFramebuf.colorTexture();
d->uMvpMatrix = ClientWindow::main().root().projMatrix2D() *
Matrix4f::scaleThenTranslate(view3D.size(), view3D.topLeft);
d->frameDrawable.draw();
}

// Some of the layers use OpenGL 2 drawing code.
DGL_MatrixMode(DGL_PROJECTION);
DGL_PushMatrix();
LIBGUI_GL.glLoadMatrixf(ClientWindow::main().root().projMatrix2D().values());

// Fill around a scaled-down 3D view. The border is not visible if the 3D view
// covers the entire area.
{
R_RenderPlayerViewBorder();
}

// Game HUD.
{
/// @todo HUD rendering probably doesn't need the vdWindow.

auto const *vp = R_CurrentViewPort();
RectRaw vpGeometry(vp->geometry.topLeft.x, vp->geometry.topLeft.y,
vp->geometry.width(), vp->geometry.height());

viewdata_t const *vd = &DD_Player(d->playerNum)->viewport();
RectRaw vdWindow(vd->window.topLeft.x, vd->window.topLeft.y,
vd->window.width(), vd->window.height());

if (gx.DrawViewPort)
{
GLState::current()
.setBlend(true)
.apply();

gx.DrawViewPort(P_ConsoleToLocal(d->playerNum),
&vpGeometry,
&vdWindow,
displayPlayer,
/* layer: */ 1);
}
}

// Finale.
{

}

// Non-map game screens.
{

}

// Legacy engine/debug UIs (stuff from the old Net_Drawer).
{

}

// Restore the default drawing state.
R_UseViewPort(nullptr);
displayPlayer = oldDisplayPlayer;

DGL_MatrixMode(DGL_PROJECTION);
DGL_PopMatrix();

GLState::pop().apply();
}
3 changes: 1 addition & 2 deletions doomsday/apps/client/src/ui/widgets/gamewidget.cpp
Expand Up @@ -91,7 +91,7 @@ DENG2_PIMPL(GameWidget)
{
ClientApp::app().forLocalPlayers([this] (ClientPlayer &player)
{
player.viewCompositor().drawCompositedLayers(self.rule().recti());
player.viewCompositor().drawCompositedLayers();
return LoopContinue;
});
}
Expand Down Expand Up @@ -157,7 +157,6 @@ GameWidget::GameWidget(String const &name)

void GameWidget::glApplyViewport(Rectanglei const &rect)
{
qDebug() << "glApplyViewport:" << rect.asText();
GLState::current()
.setNormalizedViewport(normalizedRect(rect))
.apply();
Expand Down

0 comments on commit 1a52664

Please sign in to comment.