Skip to content

Commit

Permalink
GRAPHICS: Condense renderGUI{Front,Back} to one function
Browse files Browse the repository at this point in the history
  • Loading branch information
farmboy0 committed Dec 13, 2017
1 parent 5dbe34c commit 42a002e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
48 changes: 13 additions & 35 deletions src/graphics/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,43 +960,20 @@ bool GraphicsManager::renderWorld() {
}

bool GraphicsManager::renderGUIFront() {
if (QueueMan.isQueueEmpty(kQueueVisibleGUIFrontObject))
return false;

glDisable(GL_DEPTH_TEST);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glScalef(2.0f / WindowMan.getWindowWidth(), 2.0f / WindowMan.getWindowHeight(), 0.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

QueueMan.lockQueue(kQueueVisibleGUIFrontObject);
const std::list<Queueable *> &gui = QueueMan.getQueue(kQueueVisibleGUIFrontObject);

buildNewTextures();

for (std::list<Queueable *>::const_reverse_iterator g = gui.rbegin();
g != gui.rend(); ++g) {

glPushMatrix();
static_cast<Renderable *>(*g)->render(kRenderPassAll);
glPopMatrix();
}

QueueMan.unlockQueue(kQueueVisibleGUIFrontObject);

glEnable(GL_DEPTH_TEST);
return true;
return renderGUI(kQueueVisibleGUIFrontObject, false);
}

bool GraphicsManager::renderGUIBack() {
if (QueueMan.isQueueEmpty(kQueueVisibleGUIBackObject))
return renderGUI(kQueueVisibleGUIBackObject, true);
}

bool GraphicsManager::renderGUI(QueueType guiQueue, bool disableDepthMask) {
if (QueueMan.isQueueEmpty(guiQueue))
return false;

glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
if (disableDepthMask)
glDepthMask(GL_FALSE);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
Expand All @@ -1005,8 +982,8 @@ bool GraphicsManager::renderGUIBack() {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

QueueMan.lockQueue(kQueueVisibleGUIBackObject);
const std::list<Queueable *> &gui = QueueMan.getQueue(kQueueVisibleGUIBackObject);
QueueMan.lockQueue(guiQueue);
const std::list<Queueable *> &gui = QueueMan.getQueue(guiQueue);

buildNewTextures();

Expand All @@ -1018,9 +995,10 @@ bool GraphicsManager::renderGUIBack() {
glPopMatrix();
}

QueueMan.unlockQueue(kQueueVisibleGUIBackObject);
QueueMan.unlockQueue(guiQueue);

glDepthMask(GL_TRUE);
if (disableDepthMask)
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/graphics/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class GraphicsManager : public Common::Singleton<GraphicsManager>, public Events
bool renderWorld();
bool renderGUIFront();
bool renderGUIBack();
bool renderGUI(QueueType guiQueue, bool disableDepthMask);
bool renderCursor();
void endScene();

Expand Down

0 comments on commit 42a002e

Please sign in to comment.