From a472ef6057e18c671a48f3018fc4354e593cd935 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 26 Jan 2015 00:18:09 +0100 Subject: [PATCH] Updating lights on creation and also using constant. --- graphics.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/graphics.cc b/graphics.cc index 909cd5d..5384fc4 100644 --- a/graphics.cc +++ b/graphics.cc @@ -8,6 +8,7 @@ using namespace ACGL::OpenGL; const int Graphics::cube_size = 1024; +const double lightUpdateDelay = 0.5f; Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) { this->windowSize = windowSize; @@ -16,13 +17,15 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) { } Graphics::Graphics() { - lastUpdate = 0.0f; } void Graphics::init(Level* level) { // save Level this->level = level; + // update lights on creation + lastUpdate = -lightUpdateDelay; + // construct VAO to give shader correct Attribute locations SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer()); ab->defineAttribute("aPosition", GL_FLOAT, 3); @@ -128,7 +131,7 @@ void Graphics::render(double time) // TODO look into doing this less often, offload to another thread? // TODO figure out how to deal with bigger numbers of lights. load the nearest on demand? - double nextUpdate = lastUpdate + 0.5f; + double nextUpdate = lastUpdate + lightUpdateDelay; if (time >= nextUpdate) { updateLights();