From: Andy Belle-Isle Date: Wed, 9 Oct 2019 20:18:25 +0000 (-0400) Subject: Moved camera position updating to the beginning of the render loop to fix stuttering... X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=57a1eb6fdccb9023557d0a470796f423f063948a;p=clyne%2Fgamedev2.git Moved camera position updating to the beginning of the render loop to fix stuttering caused by extremely fast movements --- diff --git a/src/render.cpp b/src/render.cpp index 9362134..0c60eed 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -69,6 +69,20 @@ void RenderSystem::update([[maybe_unused]] entityx::EntityManager& entities, glEnable(GL_CULL_FACE); glEnable(GL_POLYGON_OFFSET_FILL); + /************ + * CAMERA * + ************/ + try { + if (player.has_component()) { + Position *pos = player.component().get(); + camPos.y = pos->y; + camPos.x = pos->x; + } + } catch (...) { // If the player doesn't exist or anything goes wrong + camPos.y = 0.0f; + camPos.x = 0.0f; + } + glm::mat4 view = glm::lookAt(camPos, // Pos camPos + rot, // Facing @@ -101,7 +115,6 @@ void RenderSystem::update([[maybe_unused]] entityx::EntityManager& entities, glUseProgram(s); - glUniformMatrix4fv(v, 1, GL_FALSE, glm::value_ptr(view)); glUniformMatrix4fv(p, 1, GL_FALSE, glm::value_ptr(projection)); glUniformMatrix4fv(m, 1, GL_FALSE, glm::value_ptr(model)); @@ -114,20 +127,6 @@ void RenderSystem::update([[maybe_unused]] entityx::EntityManager& entities, GLfloat amb[4] = {1.0f, 1.0f, 1.0f, 0.0f}; glUniform4fv(b, 1, amb); - /************ - * CAMERA * - ************/ - try { - if (player.has_component()) { - Position *pos = player.component().get(); - camPos.y = pos->y; - camPos.x = pos->x; - } - } catch (...) { // If the player doesn't exist or anything goes wrong - camPos.y = 0.0f; - camPos.x = 0.0f; - } - /************** * LIGHTING * **************/