Updating lights on creation and also using constant.
This commit is contained in:
parent
9eab39d521
commit
a472ef6057
@ -8,6 +8,7 @@
|
|||||||
using namespace ACGL::OpenGL;
|
using namespace ACGL::OpenGL;
|
||||||
|
|
||||||
const int Graphics::cube_size = 1024;
|
const int Graphics::cube_size = 1024;
|
||||||
|
const double lightUpdateDelay = 0.5f;
|
||||||
|
|
||||||
Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) {
|
Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) {
|
||||||
this->windowSize = windowSize;
|
this->windowSize = windowSize;
|
||||||
@ -16,13 +17,15 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Graphics::Graphics() {
|
Graphics::Graphics() {
|
||||||
lastUpdate = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::init(Level* level) {
|
void Graphics::init(Level* level) {
|
||||||
// save Level
|
// save Level
|
||||||
this->level = level;
|
this->level = level;
|
||||||
|
|
||||||
|
// update lights on creation
|
||||||
|
lastUpdate = -lightUpdateDelay;
|
||||||
|
|
||||||
// construct VAO to give shader correct Attribute locations
|
// construct VAO to give shader correct Attribute locations
|
||||||
SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer());
|
SharedArrayBuffer ab = SharedArrayBuffer(new ArrayBuffer());
|
||||||
ab->defineAttribute("aPosition", GL_FLOAT, 3);
|
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 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?
|
// 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)
|
if (time >= nextUpdate)
|
||||||
{
|
{
|
||||||
updateLights();
|
updateLights();
|
||||||
|
Loading…
Reference in New Issue
Block a user