Skip to content

Commit

Permalink
Fix a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopson97 committed Jul 28, 2017
1 parent de25f87 commit d4d72f1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
17 changes: 11 additions & 6 deletions Source/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ void Application::runMainGameLoop()
m_camera.update();
state.update(m_camera, elapsed.asSeconds());

m_renderer.clear();
state.draw(m_renderer);
m_renderer.update(m_camera);
handleEvents();

if (m_shouldPop)
{
m_shouldPop = false;
m_states.pop_back();
if (!m_states.empty())
{
currentState().onOpen();
}
}
}
}

Expand Down Expand Up @@ -85,11 +94,7 @@ void Application::handleEvents()

void Application::popState()
{
m_states.pop_back();
if (!m_states.empty())
{
currentState().onOpen();
}
m_shouldPop = true;
}

StateBase& Application::currentState()
Expand Down
2 changes: 2 additions & 0 deletions Source/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Application
std::vector<std::unique_ptr<StateBase>> m_states;
MasterRenderer m_renderer;
Camera m_camera;

bool m_shouldPop = false;
};

#endif // APPLICATION_H_INCLUDED
6 changes: 0 additions & 6 deletions Source/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ void Display::close()
m_window.close();
}

void Display::clear()
{
glClearColor(0.1, 0.5, 1.0, 1.0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}

void Display::update()
{
m_window.display();
Expand Down
1 change: 0 additions & 1 deletion Source/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Display : public Singleton

void close();

void clear();
void update();

bool isOpen();
Expand Down
8 changes: 3 additions & 5 deletions Source/Renderer/MasterRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

#include "../Camera.h"

void MasterRenderer::clear()
{
Display::get().clear();
}

void MasterRenderer::update(const Camera& camera)
{
glClearColor(0.1, 0.5, 1.0, 1.0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

BlockDatabase::get().getTextureAtlas().bind();

glEnable(GL_DEPTH_TEST);
Expand Down
2 changes: 0 additions & 2 deletions Source/Renderer/MasterRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ struct Camera;
class MasterRenderer
{
public:
void clear();

void update(const Camera& camera);

void draw(const Vector3& location);
Expand Down

0 comments on commit d4d72f1

Please sign in to comment.