]> git.tdb.fi Git - libs/gl.git/blobdiff - source/lighting.cpp
Better state tracking for bound objects
[libs/gl.git] / source / lighting.cpp
index 0af2416c14729788d411e747b91e8bcedfa0303c..aae5d331384919e0af9f8523523eda56a5273bab 100644 (file)
@@ -20,6 +20,8 @@ void Lighting::attach(unsigned i, const Light &l)
                lights.resize(i+1);
 
        lights[i] = &l;
+       if(current()==this)
+               l.bind_to(i);
 }
 
 void Lighting::detach(unsigned i)
@@ -28,6 +30,8 @@ void Lighting::detach(unsigned i)
                return;
 
        lights[i] = 0;
+       if(current()==this)
+               Light::unbind_from(i);
 }
 
 void Lighting::bind() const