Fixing the rendering of the shadows. Closes #10.

This commit is contained in:
Faerbit 2015-06-02 17:36:55 +02:00
parent e8c1dee3b5
commit ea8e7b6048

View File

@ -680,32 +680,32 @@ void Graphics::updateLights() {
} }
// Build light position array // Build light position array
glm::vec3 lightSources[closestLights->size()]; glm::vec3 lightSources[shadowRenderQueue.size()];
for(unsigned int i = 0; i<closestLights->size(); i++) { for(unsigned int i = 0; i<shadowRenderQueue.size(); i++) {
lightSources[i] = closestLights->at(i)->getPosition(); lightSources[i] = shadowRenderQueue.at(i).light->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[closestLights->size()]; glm::vec3 lightColours[shadowRenderQueue.size()];
for(unsigned int i = 0; i<closestLights->size(); i++) { for(unsigned int i = 0; i<shadowRenderQueue.size(); i++) {
lightColours[i] = closestLights->at(i)->getColour(); lightColours[i] = shadowRenderQueue.at(i).light->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[closestLights->size()]; float lightIntensities[shadowRenderQueue.size()];
for(unsigned int i = 0; i<closestLights->size(); i++) { for(unsigned int i = 0; i<shadowRenderQueue.size(); i++) {
lightIntensities[i] = closestLights->at(i)->getIntensity(); lightIntensities[i] = shadowRenderQueue.at(i).light->getIntensity();
} }
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"), glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
sizeof(lightIntensities), (GLfloat*) lightIntensities); sizeof(lightIntensities), (GLfloat*) lightIntensities);
bool isFlame[closestLights->size()]; bool isFlame[shadowRenderQueue.size()];
closestFlames = std::vector<Flame*>(); closestFlames = std::vector<Flame*>();
for (unsigned int i = 0; i<closestLights->size(); i++) { for(unsigned int i = 0; i<shadowRenderQueue.size(); i++) {
if (closestLights->at(i)->isFlame()) { if (shadowRenderQueue.at(i).light->isFlame()) {
closestFlames.push_back(closestLights->at(i)->getFlame()); closestFlames.push_back(shadowRenderQueue.at(i).light->getFlame());
isFlame[i] = true; isFlame[i] = true;
} }
else { else {