Fixed exit crash(es)

This commit is contained in:
2016-01-06 11:20:16 +01:00
parent c133223bac
commit 34cbbb3eb1
5 changed files with 21 additions and 49 deletions
+4 -6
View File
@@ -1,5 +1,4 @@
#include "Rendering/Renderer.h"
#include "Rendering/DebugCameraInputController.h"
void Renderer::Initialize()
{
@@ -10,6 +9,7 @@ void Renderer::Initialize()
if (m_Camera == nullptr) {
m_Camera = m_DefaultCamera;
}
m_DebugCameraInputController = std::make_shared<DebugCameraInputController<Renderer>>(m_EventBroker, -1);
TEMPCreateLights();
InitializeRenderPasses();
@@ -89,8 +89,6 @@ void Renderer::InitializeShaders()
void Renderer::InputUpdate(double dt)
{
static DebugCameraInputController<Renderer> firstPersonInputController(m_EventBroker, -1);
glm::vec3 m_Position = m_Camera->Position();
if (glfwGetKey(m_Window, GLFW_KEY_O) == GLFW_PRESS)
{
@@ -120,9 +118,9 @@ void Renderer::InputUpdate(double dt)
m_CameraMoveSpeed = 0.5f;
}
firstPersonInputController.Update(dt);
m_Camera->SetOrientation(firstPersonInputController.Orientation());
m_Camera->SetPosition(firstPersonInputController.Position());
m_DebugCameraInputController->Update(dt);
m_Camera->SetOrientation(m_DebugCameraInputController->Orientation());
m_Camera->SetPosition(m_DebugCameraInputController->Position());
}
void Renderer::Update(double dt)
+7 -39
View File
@@ -27,7 +27,7 @@ Game::Game(int argc, char* argv[])
0,
m_Config->Get<int>("Video.Width", 1280),
m_Config->Get<int>("Video.Height", 720)
));
));
m_Renderer->Initialize();
m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
@@ -64,17 +64,17 @@ Game::Game(int argc, char* argv[])
networkFunction();
}
m_LastTime = glfwGetTime();
debugInitialize();
}
Game::~Game()
{
// Call before to ensure that thread closes correctly.
//if (m_IsClientOrServer)
// m_ClientOrServer.Close();
delete m_SystemPipeline;
delete m_World;
delete m_FrameStack;
delete m_InputProxy;
delete m_InputManager;
delete m_Renderer;
delete m_RenderQueueFactory;
delete m_EventBroker;
}
@@ -103,7 +103,6 @@ void Game::Tick()
// Iterate through systems and update world!
m_SystemPipeline->Update(m_World, dt);
debugTick(dt);
m_Renderer->Update(dt);
m_EventBroker->Process<Client>();
@@ -115,37 +114,6 @@ void Game::Tick()
m_EventBroker->Clear();
}
bool Game::debugOnInputCommand(const Events::InputCommand& e)
{
if (e.Command == "DebugReload" && e.Value == 1) {
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
if (!mapToLoad.empty()) {
delete m_World;
m_World = new World();
ResourceManager::Release("EntityXMLFile", mapToLoad);
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
}
}
if (e.Command == "SwitchToServer" && e.Value > 0) {
m_ClientOrServer = new Server();
LOG_INFO("Switching to server");
m_ClientOrServer->Start(m_World, m_EventBroker);
}
if (e.Command == "SwitchToClient" && e.Value > 0) {
m_ClientOrServer = new Client(m_Config);
m_ClientOrServer->Start(m_World, m_EventBroker);
LOG_INFO("Switching to client");
}
return false;
}
void Game::debugInitialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Game::debugOnInputCommand);
}
void Game::debugTick(double dt)
{
m_EventBroker->Process<Game>();