aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Belle-Isle <drumsetmonkey@gmail.com>2019-10-09 16:18:25 -0400
committerAndy Belle-Isle <drumsetmonkey@gmail.com>2019-10-09 16:18:25 -0400
commit57a1eb6fdccb9023557d0a470796f423f063948a (patch)
treeb1c276b5e8c2a27f0f2a2f9d00278cb2f429d727
parentf8b062e3fe43ece368c99d1083a929de92b7cff2 (diff)
Moved camera position updating to the beginning of the render loop to fix stuttering caused by extremely fast movements
-rw-r--r--src/render.cpp29
1 files changed, 14 insertions, 15 deletions
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>()) {
+ Position *pos = player.component<Position>().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>()) {
- Position *pos = player.component<Position>().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 *
**************/