Skip to content

Commit

Permalink
Refactor|Client: Moved main loop drawing to LegacyWidget
Browse files Browse the repository at this point in the history
The actual drawing of the main loop now occurs in the LegacyWidget.

Todo: Move time update and event handling, too.
  • Loading branch information
skyjake committed Feb 24, 2013
1 parent 5826480 commit 39b2dbb
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 73 deletions.
1 change: 1 addition & 0 deletions doomsday/client/include/games.h
Expand Up @@ -22,6 +22,7 @@
#define LIBDENG_GAMES_H

#include "game.h"
#include "dd_share.h"
#include <de/types.h>
#include <de/str.h>
#include <QList>
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/render/rendpoly.h
Expand Up @@ -23,6 +23,7 @@
#define LIBDENG_RENDER_RENDPOLY_H

#include "color.h"
#include "api_gl.h"
#include <de/vector1.h>

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/dd_input.h
Expand Up @@ -28,6 +28,7 @@

#include <de/smoother.h>
#include <de/ddstring.h>
#include "api_event.h"

#if _DEBUG
# include <de/point.h> // For the debug visual.
Expand Down
13 changes: 2 additions & 11 deletions doomsday/client/include/ui/window.h
Expand Up @@ -29,10 +29,7 @@

#include "dd_types.h"
#include "resource/image.h"

#ifdef __cplusplus
extern "C" {
#endif
#include "canvaswindow.h"

#define WINDOW_MIN_WIDTH 320
#define WINDOW_MIN_HEIGHT 240
Expand Down Expand Up @@ -340,17 +337,11 @@ void Window_GLDone(Window* wnd);

void* Window_NativeHandle(const Window* wnd);

#ifdef __cplusplus
} // extern "C"

// C++ API
class QWidget;

/**
* Returns the window's native widget, if one exists.
*/
QWidget* Window_Widget(Window* wnd);

#endif // __cplusplus
CanvasWindow *Window_CanvasWindow(Window *wnd);

#endif /* LIBDENG_SYS_WINDOW_H */
63 changes: 3 additions & 60 deletions doomsday/client/src/dd_loop.cpp
Expand Up @@ -67,8 +67,6 @@ boolean stopTime = false; // If true the time counters won't be incremented
boolean tickUI = false; // If true the UI will be tick'd
boolean tickFrame = true; // If false frame tickers won't be tick'd (unless netGame)

boolean drawGame = true; // If false the game viewport won't be rendered

static int gameLoopExitCode = 0;

static double lastRunTicsTime;
Expand Down Expand Up @@ -237,65 +235,10 @@ void DD_GameLoopDrawer(void)
glClear(GL_COLOR_BUFFER_BIT);
}

if(drawGame)
{
if(App_GameLoaded())
{
// Interpolate the world ready for drawing view(s) of it.
if(theMap)
{
R_BeginWorldFrame();
}
R_RenderViewPorts();
}
else if(titleFinale == 0)
{
// Title finale is not playing. Lets do it manually.
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1, 1);

R_RenderBlankView();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
}

if(!(UI_IsActive() && UI_Alpha() >= 1.0))
{
UI2_Drawer();

// Draw any full window game graphics.
if(App_GameLoaded() && gx.DrawWindow)
gx.DrawWindow(Window_Size(theWindow));
}
}

if(Con_TransitionInProgress())
Con_DrawTransition();

if(drawGame)
{
// Debug information.
Net_Drawer();
S_Drawer();

// Finish up any tasks that must be completed after view(s) have been drawn.
R_EndWorldFrame();
}

if(UI_IsActive())
{
// Draw user interface.
UI_Drawer();
}

// Draw console.
Rend_Console();
CanvasWindow *win = Window_CanvasWindow(Window_Main());
DENG_ASSERT(win != 0);

// End any open DGL sequence.
DGL_End();
win->root().draw();

// Finish GL drawing and swap it on to the screen.
GL_DoUpdate();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/vignette.cpp
Expand Up @@ -79,7 +79,7 @@ void Vignette_Render(const RectRaw* viewRect, float fov)
glBegin(GL_TRIANGLE_STRIP);
for(i = 0; i <= DIVS; ++i)
{
float ang = (float)(2 * PI * i) / (float)DIVS;
float ang = (float)(2 * de::PI * i) / (float)DIVS;
float dx = cos(ang);
float dy = sin(ang);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/busyvisual.cpp
Expand Up @@ -266,7 +266,7 @@ static void drawPositionIndicator(float x, float y, float radius, float pos,
// Vertices along the edge.
for(i = 0; i <= edgeCount; ++i)
{
float angle = 2 * PI * pos * (i / (float)edgeCount) + PI/2;
float angle = 2 * de::PI * pos * (i / (float)edgeCount) + de::PI/2;
glTexCoord2f(.5f + cos(angle)*.5f, .5f + sin(angle)*.5f);
glVertex2f(x + cos(angle)*radius*1.05f, y + sin(angle)*radius*1.05f);
}
Expand Down
72 changes: 72 additions & 0 deletions doomsday/client/src/ui/legacywidget.cpp
Expand Up @@ -17,6 +17,19 @@
*/

#include "ui/legacywidget.h"
#include "ui/dd_input.h"
#include "ui/ui_main.h"
#include "ui/ui2_main.h"
#include "ui/busyvisual.h"
#include "dd_main.h"
#include "map/gamemap.h"
#include "network/net_main.h"
#include "render/rend_list.h"
#include "render/rend_console.h"
#include "audio/s_main.h"
#include "gl/sys_opengl.h"

boolean drawGame = true; // If false the game viewport won't be rendered

using namespace de;

Expand Down Expand Up @@ -45,6 +58,65 @@ void LegacyWidget::update()

void LegacyWidget::draw()
{
if(drawGame)
{
if(App_GameLoaded())
{
// Interpolate the world ready for drawing view(s) of it.
if(theMap)
{
R_BeginWorldFrame();
}
R_RenderViewPorts();
}
else if(titleFinale == 0)
{
// Title finale is not playing. Lets do it manually.
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1, 1);

R_RenderBlankView();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
}

if(!(UI_IsActive() && UI_Alpha() >= 1.0))
{
UI2_Drawer();

// Draw any full window game graphics.
if(App_GameLoaded() && gx.DrawWindow)
gx.DrawWindow(Window_Size(theWindow));
}
}

if(Con_TransitionInProgress())
Con_DrawTransition();

if(drawGame)
{
// Debug information.
Net_Drawer();
S_Drawer();

// Finish up any tasks that must be completed after view(s) have been drawn.
R_EndWorldFrame();
}

if(UI_IsActive())
{
// Draw user interface.
UI_Drawer();
}

// Draw console.
Rend_Console();

// End any open DGL sequence.
DGL_End();
}

bool LegacyWidget::handleEvent(Event const &/*event*/)
Expand Down
6 changes: 6 additions & 0 deletions doomsday/client/src/ui/window.cpp
Expand Up @@ -1584,3 +1584,9 @@ QWidget* Window_Widget(Window* wnd)
if(!wnd) return 0;
return wnd->widget;
}

CanvasWindow *Window_CanvasWindow(Window *wnd)
{
if(!wnd) return 0;
return wnd->widget;
}

0 comments on commit 39b2dbb

Please sign in to comment.