From 5b2c4a6bbc7221f98cb6787710165c232699a087 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Fri, 19 Dec 2014 13:09:25 +0100 Subject: [PATCH] Fixed crashing if no lights are present. --- graphics.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/graphics.cc b/graphics.cc index 014b0cb..f23faad 100644 --- a/graphics.cc +++ b/graphics.cc @@ -72,8 +72,8 @@ void Graphics::init(Level* level) { /*depth_cubeMaps = std::vector(level->getLights()->size()); for (unsigned int i = 0; i(1); - for (unsigned int i = 0; i<1; i++) { + depth_cubeMaps = std::vector(std::min(int(level->getLights()->size()), 1)); + for (unsigned int i = 0; i<1 && isetMinFilter(GL_NEAREST); depth_cubeMaps.at(i)->setMagFilter(GL_NEAREST); @@ -105,7 +105,7 @@ void Graphics::render() framebuffer_cube->bind(); //for (unsigned int i_pointlight = 0; i_pointlightgetLights()->size(); i_pointlight++) { - for (unsigned int i_pointlight = 0; i_pointlight<1; i_pointlight++) { + for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlightgetLights()->size(); i_pointlight++) { // render each side of the cube for (int i_face = 0; i_face<6; i_face++) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);