From b5887904192309b37cf0607c546dce2c85fadfa8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 12 Aug 2016 23:39:33 +0300 Subject: [PATCH] Some fixes to lighting management --- source/lighting.cpp | 11 +++++++++++ source/lightunit.cpp | 1 - source/lightunit.h | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/lighting.cpp b/source/lighting.cpp index 5cda4f4c..ce522ac0 100644 --- a/source/lighting.cpp +++ b/source/lighting.cpp @@ -104,14 +104,25 @@ void Lighting::bind() const if(lights.size()>LightUnit::get_n_units()) throw invalid_operation("Lighting::bind"); + const Lighting *old = current(); if(!set_current(this)) return; enable(GL_LIGHTING); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &ambient.r); for(unsigned i=0; ibind_to(i); + else + Light::unbind_from(i); + } + + if(old) + { + for(unsigned i=lights.size(); ilights.size(); ++i) + Light::unbind_from(i); + } if(fog_density) { diff --git a/source/lightunit.cpp b/source/lightunit.cpp index 3eb32929..e7cf7419 100644 --- a/source/lightunit.cpp +++ b/source/lightunit.cpp @@ -10,7 +10,6 @@ namespace Msp { namespace GL { vector LightUnit::units; -LightUnit *LightUnit::cur_unit = 0; LightUnit::LightUnit(): light(0) diff --git a/source/lightunit.h b/source/lightunit.h index 658712df..bc200ea4 100644 --- a/source/lightunit.h +++ b/source/lightunit.h @@ -15,7 +15,6 @@ private: const Light *light; static std::vector units; - static LightUnit *cur_unit; LightUnit(); -- 2.45.2