Skip to content
Snippets Groups Projects
Commit 9b916e92 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

ensure game scenes without cameras do not crash

parent 87f26504
No related branches found
No related tags found
No related merge requests found
...@@ -207,7 +207,11 @@ namespace fggl::gfx { ...@@ -207,7 +207,11 @@ namespace fggl::gfx {
if ( m_debugRenderer ) { if ( m_debugRenderer ) {
auto cameras = world.findMatching<gfx::Camera>(); auto cameras = world.findMatching<gfx::Camera>();
auto cameraEnt = cameras[0]; if ( cameras.empty() ) {
return;
}
auto cameraEnt = cameras.front();
auto* const camTransform = world.get<math::Transform>(cameraEnt); auto* const camTransform = world.get<math::Transform>(cameraEnt);
auto* const camComp = world.get<gfx::Camera>(cameraEnt); auto* const camComp = world.get<gfx::Camera>(cameraEnt);
......
...@@ -43,6 +43,8 @@ namespace fggl::scenes { ...@@ -43,6 +43,8 @@ namespace fggl::scenes {
} }
void Game::update() { void Game::update() {
assert( m_world );
if ( m_input != nullptr ) { if ( m_input != nullptr ) {
bool escapePressed = m_input->keyboard.pressed(glfwGetKeyScancode(GLFW_KEY_ESCAPE)); bool escapePressed = m_input->keyboard.pressed(glfwGetKeyScancode(GLFW_KEY_ESCAPE));
if (escapePressed) { if (escapePressed) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment