]> git.tdb.fi Git - libs/gl.git/commitdiff
Only check against number of light units when binding Lighting
authorMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 19:28:51 +0000 (22:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 19:28:51 +0000 (22:28 +0300)
Feeding lights to shaders through ProgramData is not subject to
GL_MAX_LIGHTS, it makes sense to remove that limit from attaching them.

source/lighting.cpp

index 2ba1edc5560e00889ecd31fa01592f121a68a993..7f662c72d9ccf55bdb0e5e8831706b9781709360 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdexcept>
+#include "error.h"
 #include "light.h"
 #include "lighting.h"
 #include "lightunit.h"
@@ -38,9 +39,6 @@ void Lighting::set_horizon_angle(const Geometry::Angle<float> &a)
 
 void Lighting::attach(unsigned i, const Light &l)
 {
-       if(i>=LightUnit::get_n_units())
-               throw out_of_range("Lighting::attach");
-
        if(i>=lights.size())
                lights.resize(i+1);
 
@@ -73,6 +71,9 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix
 
 void Lighting::bind() const
 {
+       if(lights.size()>LightUnit::get_n_units())
+               throw invalid_operation("Lighting::bind");
+
        if(!set_current(this))
                return;