X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fmaterials%2Flighting.cpp;h=c1b2e2aaf0a02619fb17f9a1e06f456bc27fdd1a;hb=ae45c0397e2cb8f0a01f2f31d01c95ff3870271e;hp=20c812fe58cfd3e6ee7434bef5f10707db67f01c;hpb=5008778dbb1840bf7c6d479800d2b932f8386fb2;p=libs%2Fgl.git diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 20c812fe..c1b2e2aa 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -17,6 +17,14 @@ Lighting::Lighting() set_ambient(0.2f); set_fog_color(Color(0.0f, 0.0f, 0.0f, 0.0f)); set_fog_density(0.0f); + + for(unsigned i=0; i<8; ++i) + { + string base = format("light_sources[%d]", i); + shdata.uniform(base+".position", Vector4(0, 0, 1, 0)); + shdata.uniform(base+".color", 0.0f, 0.0f, 0.0f); + shdata.uniform(base+".enabled", 0); + } } void Lighting::set_ambient(const Color &a) @@ -55,7 +63,16 @@ void Lighting::detach(const Light &l) { auto i = find_member(lights, &l, &AttachedLight::light); if(i!=lights.end()) + { lights.erase(i); + shdata.uniform(format("light_sources[%d].enabled", lights.size()), 0); + } +} + +int Lighting::find_light_index(const Light &l) const +{ + auto i = find_member(lights, &l, &AttachedLight::light); + return (i!=lights.end() ? i-lights.begin() : -1); } const ProgramData &Lighting::get_shader_data() const @@ -82,12 +99,6 @@ void Lighting::set_debug_name(const string &name) DataFile::Loader::ActionMap Lighting::Loader::shared_actions; -Lighting::Loader::Loader(Lighting &l): - CollectionObjectLoader(l, 0) -{ - set_actions(shared_actions); -} - Lighting::Loader::Loader(Lighting &l, Collection &c): CollectionObjectLoader(l, &c) {