]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Moved camera position updating to the beginning of the render loop to fix stuttering...
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 9 Oct 2019 20:18:25 +0000 (16:18 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 9 Oct 2019 20:18:25 +0000 (16:18 -0400)
src/render.cpp

index 9362134796ea17fb1060a38afb0b280c5670358c..0c60eed18837f5eb70df110369fb0bfad32d6914 100644 (file)
@@ -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  *
     **************/