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);
|
||||
|
||||
//set lighting parameters
|
||||
if (level->getLights().size() > 0) {
|
||||
lightingShader->setUniform("lightCount", (int) level->getLights().size());
|
||||
if (level->getLights()->size() > 0) {
|
||||
lightingShader->setUniform("lightCount", (int) level->getLights()->size());
|
||||
|
||||
// TODO look into doing this less often
|
||||
// Build light position array
|
||||
glm::vec3 lightSources[level->getLights().size()];
|
||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
||||
lightSources[i] = level->getLights()[i].getPosition();
|
||||
glm::vec3 lightSources[level->getLights()->size()];
|
||||
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||
lightSources[i] = level->getLights()->at(i).getPosition();
|
||||
}
|
||||
glUniform3fv(lightingShader->getUniformLocation("lightSources"),
|
||||
sizeof(lightSources), (GLfloat*) lightSources);
|
||||
// Build light colour array
|
||||
glm::vec3 lightColours[level->getLights().size()];
|
||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
||||
lightColours[i] = level->getLights()[i].getColour();
|
||||
glm::vec3 lightColours[level->getLights()->size()];
|
||||
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||
lightColours[i] = level->getLights()->at(i).getColour();
|
||||
}
|
||||
glUniform3fv(lightingShader->getUniformLocation("lightColors"),
|
||||
sizeof(lightColours), (GLfloat*) lightColours);
|
||||
// Build light attenuation array
|
||||
float lightIntensities[level->getLights().size()];
|
||||
for(unsigned int i = 0; i<level->getLights().size(); i++) {
|
||||
lightIntensities[i] = level->getLights()[i].getIntensity();
|
||||
float lightIntensities[level->getLights()->size()];
|
||||
for(unsigned int i = 0; i<level->getLights()->size(); i++) {
|
||||
lightIntensities[i] = level->getLights()->at(i).getIntensity();
|
||||
}
|
||||
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
|
||||
sizeof(lightIntensities), (GLfloat*) lightIntensities);
|
||||
|
4
level.cc
4
level.cc
@ -349,8 +349,8 @@ glm::vec3 Level::getAmbientLight() {
|
||||
return ambientLight;
|
||||
}
|
||||
|
||||
std::vector<Light> Level::getLights() {
|
||||
return lights;
|
||||
std::vector<Light>* Level::getLights() {
|
||||
return &lights;
|
||||
}
|
||||
|
||||
Camera* Level::getCamera() {
|
||||
|
2
level.hh
2
level.hh
@ -21,7 +21,7 @@ class Level {
|
||||
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass);
|
||||
glm::vec3 getAmbientLight();
|
||||
Light* getDirectionalLight();
|
||||
std::vector<Light> getLights();
|
||||
std::vector<Light>* getLights();
|
||||
Object* getCameraCenter();
|
||||
Camera* getCamera();
|
||||
glm::vec3 getCameraPosition();
|
||||
|
Loading…
Reference in New Issue
Block a user