Skip to content

Commit

Permalink
UI|Client: Rendering the busy transition frame
Browse files Browse the repository at this point in the history
Instead of a custom method in ClientWindow, BusyWidget can now render
its own copy of the game view into a separate framebuffer.
This reuses the latest available player view texture(s).
  • Loading branch information
skyjake committed Oct 2, 2016
1 parent ff53cf3 commit c9b440a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/ui/clientwindow.h
Expand Up @@ -147,13 +147,13 @@ class ClientWindow : public de::BaseWindow
*/
void grab(image_t &image, bool halfSized = false) const;

/**
/*
* Draws the untransformed game-related contents of the window. The drawing
* is done immediately; this must be called from the main/UI thread.
*
* The current render target is cleared before drawing.
*/
void drawGameContent();
//void drawGameContent();

void fadeContentFromBlack(de::TimeDelta const &duration);
de::FadeToBlackWidget *contentFade();
Expand Down
6 changes: 5 additions & 1 deletion doomsday/apps/client/include/ui/widgets/busywidget.h
Expand Up @@ -22,6 +22,8 @@
#include <de/ProgressWidget>
#include <de/GLTexture>

class GameWidget;

/**
* Widget that takes care of the UI while busy mode is active.
*/
Expand All @@ -32,13 +34,15 @@ class BusyWidget : public de::GuiWidget

de::ProgressWidget &progress();

void setGameWidget(GameWidget &gameWidget);

void renderTransitionFrame();
void releaseTransitionFrame();
void clearTransitionFrameToBlack();
de::GLTexture const *transitionFrame() const;

// Events.
void viewResized();
//void viewResized();
void update();
void drawContent();
bool handleEvent(de::Event const &event);
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/include/ui/widgets/gamewidget.h
Expand Up @@ -46,6 +46,8 @@ class GameWidget : public de::GuiWidget
*/
void pause();

void drawComposited();

// Events.
void viewResized() override;
void update() override;
Expand Down
2 changes: 0 additions & 2 deletions doomsday/apps/client/src/ui/busyvisual.cpp
Expand Up @@ -151,8 +151,6 @@ static void sampleDoomWipe(void)

void Con_DrawTransition(void)
{
return; // TODO: re-enable with copied GameWidget FBO contents

if (isDedicated) return;
if (!Con_TransitionInProgress()) return;

Expand Down
3 changes: 3 additions & 0 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -226,6 +226,7 @@ DENG2_PIMPL(ClientWindow)

// Busy widget shows progress indicator and frozen game content.
busy = new BusyWidget;
busy->setGameWidget(*game);
busy->hide(); // normally hidden
busy->rule().setRect(root.viewRule());
root.add(busy);
Expand Down Expand Up @@ -1024,6 +1025,7 @@ void ClientWindow::grab(image_t &img, bool halfSized) const
DENG_ASSERT(img.pixelSize != 0);
}

/*
void ClientWindow::drawGameContent()
{
DENG_ASSERT_IN_MAIN_THREAD();
Expand All @@ -1033,6 +1035,7 @@ void ClientWindow::drawGameContent()
d->root.drawUntil(*d->home);
}
*/

void ClientWindow::fadeInTaskBarBlur(TimeDelta span)
{
Expand Down
24 changes: 14 additions & 10 deletions doomsday/apps/client/src/ui/widgets/busywidget.cpp
Expand Up @@ -39,6 +39,7 @@ DENG_GUI_PIMPL(BusyWidget)
typedef DefaultVertexBuf VertexBuf;

ProgressWidget *progress;
GameWidget *gameWidget = nullptr;
Time frameDrawnAt;
GLTextureFramebuffer transitionFrame;
Drawable drawable;
Expand Down Expand Up @@ -93,11 +94,16 @@ ProgressWidget &BusyWidget::progress()
return *d->progress;
}

void BusyWidget::viewResized()
void BusyWidget::setGameWidget(GameWidget &gameWidget)
{
GuiWidget::viewResized();
d->gameWidget = &gameWidget;
}

/*void BusyWidget::viewResized()
{
GuiWidget::viewResized();
}*/

void BusyWidget::update()
{
GuiWidget::update();
Expand Down Expand Up @@ -134,8 +140,6 @@ void BusyWidget::drawContent()

if (d->haveTransitionFrame())
{
//glDisable(GL_ALPHA_TEST); /// @todo get rid of these
//glDisable(GL_BLEND);
GLState::push()
.setAlphaTest(false)
.setBlend(false)
Expand All @@ -150,9 +154,6 @@ void BusyWidget::drawContent()
d->drawable.draw();

GLState::pop().apply();

//glEnable(GL_ALPHA_TEST);
//glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}
}
Expand All @@ -179,13 +180,14 @@ void BusyWidget::renderTransitionFrame()

DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();
DENG2_ASSERT(d->gameWidget);

Rectanglei grabRect = Rectanglei::fromSize(root().window().pixelSize());
Rectanglei grabRect = Rectanglei::fromSize(rule().recti().size());

LOGDEV_GL_VERBOSE("Rendering transition frame, size %s pixels") << grabRect.size().asText();

#if 1
/// @todo This breaks Qt's QOpenGLWidget FBO for some reason!
#if 0
d->transitionFrame.resize(grabRect.size());
if (!d->transitionFrame.isReady())
{
Expand All @@ -197,7 +199,9 @@ void BusyWidget::renderTransitionFrame()
.setViewport(Rectangleui::fromSize(d->transitionFrame.size()))
.apply();

root().window().as<ClientWindow>().drawGameContent();
d->gameWidget->drawComposited();

//root().window().as<ClientWindow>().drawGameContent();

GLState::pop().apply();

Expand Down
9 changes: 7 additions & 2 deletions doomsday/apps/client/src/ui/widgets/gamewidget.cpp
Expand Up @@ -91,7 +91,7 @@ DENG2_PIMPL(GameWidget)
* border, HUD, finale, intermission, and engine/debug overlays. This is generally
* a quick operation and can be done multiple times per window paint.
*/
void drawCompositedFrames()
void drawComposited()
{
int numLocal = 0;
ClientApp::forLocalPlayers([this, &numLocal] (ClientPlayer &player)
Expand Down Expand Up @@ -135,7 +135,7 @@ DENG2_PIMPL(GameWidget)
needFrames = false;
}

drawCompositedFrames();
drawComposited();
}

void updateSize()
Expand Down Expand Up @@ -177,6 +177,11 @@ void GameWidget::pause()
}
}

void GameWidget::drawComposited()
{
d->drawComposited();
}

void GameWidget::viewResized()
{
GuiWidget::viewResized();
Expand Down

0 comments on commit c9b440a

Please sign in to comment.