Made getLights return a pointer to avoid copying around large amounts of light data every frame.
This commit is contained in:
parent
01212ba007
commit
d45ed9060f
22
graphics.cc
22
graphics.cc
@ -145,28 +145,28 @@ void Graphics::render()
|
|||||||
lightingShader->setTexture("shadowMap_far", depthTexture_far, 3);
|
lightingShader->setTexture("shadowMap_far", depthTexture_far, 3);
|
||||||
|
|
||||||
//set lighting parameters
|
//set lighting parameters
|
||||||
if (level->getLights().size() > 0) {
|
if (level->getLights()->size() > 0) {
|
||||||
lightingShader->setUniform("lightCount", (int) level->getLights().size());
|
lightingShader->setUniform("lightCount", (int) level->getLights()->size());
|
||||||
|
|
||||||
// TODO look into doing this less often
|
// TODO look into doing this less often
|
||||||
// Build light position array
|
// Build light position array
|
||||||
glm::vec3 lightSources[level->getLights().size()];
|
glm::vec3 lightSources[level->getLights()->size()];
|
||||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||||
lightSources[i] = level->getLights()[i].getPosition();
|
lightSources[i] = level->getLights()->at(i).getPosition();
|
||||||
}
|
}
|
||||||
glUniform3fv(lightingShader->getUniformLocation("lightSources"),
|
glUniform3fv(lightingShader->getUniformLocation("lightSources"),
|
||||||
sizeof(lightSources), (GLfloat*) lightSources);
|
sizeof(lightSources), (GLfloat*) lightSources);
|
||||||
// Build light colour array
|
// Build light colour array
|
||||||
glm::vec3 lightColours[level->getLights().size()];
|
glm::vec3 lightColours[level->getLights()->size()];
|
||||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||||
lightColours[i] = level->getLights()[i].getColour();
|
lightColours[i] = level->getLights()->at(i).getColour();
|
||||||
}
|
}
|
||||||
glUniform3fv(lightingShader->getUniformLocation("lightColors"),
|
glUniform3fv(lightingShader->getUniformLocation("lightColors"),
|
||||||
sizeof(lightColours), (GLfloat*) lightColours);
|
sizeof(lightColours), (GLfloat*) lightColours);
|
||||||
// Build light attenuation array
|
// Build light attenuation array
|
||||||
float lightIntensities[level->getLights().size()];
|
float lightIntensities[level->getLights()->size()];
|
||||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||||
lightIntensities[i] = level->getLights()[i].getIntensity();
|
lightIntensities[i] = level->getLights()->at(i).getIntensity();
|
||||||
}
|
}
|
||||||
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
|
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
|
||||||
sizeof(lightIntensities), (GLfloat*) lightIntensities);
|
sizeof(lightIntensities), (GLfloat*) lightIntensities);
|
||||||
|
4
level.cc
4
level.cc
@ -349,8 +349,8 @@ glm::vec3 Level::getAmbientLight() {
|
|||||||
return ambientLight;
|
return ambientLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Light> Level::getLights() {
|
std::vector<Light>* Level::getLights() {
|
||||||
return lights;
|
return &lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera* Level::getCamera() {
|
Camera* Level::getCamera() {
|
||||||
|
2
level.hh
2
level.hh
@ -21,7 +21,7 @@ class Level {
|
|||||||
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass);
|
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass);
|
||||||
glm::vec3 getAmbientLight();
|
glm::vec3 getAmbientLight();
|
||||||
Light* getDirectionalLight();
|
Light* getDirectionalLight();
|
||||||
std::vector<Light> getLights();
|
std::vector<Light>* getLights();
|
||||||
Object* getCameraCenter();
|
Object* getCameraCenter();
|
||||||
Camera* getCamera();
|
Camera* getCamera();
|
||||||
glm::vec3 getCameraPosition();
|
glm::vec3 getCameraPosition();
|
||||||
|
Loading…
Reference in New Issue
Block a user