X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Flighting.cpp;fp=source%2Fmaterials%2Flighting.cpp;h=cd04d1b4af153a981973c75e7eb8ff642d8f7545;hb=d4b030f46c3a643e813cf31e3faa2b4f3662a160;hp=20c812fe58cfd3e6ee7434bef5f10707db67f01c;hpb=641e5ebbda682a6df6f84a4627e3728dbcef3683;p=libs%2Fgl.git diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 20c812fe..cd04d1b4 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,10 @@ 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); + } } const ProgramData &Lighting::get_shader_data() const