X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Flighting.cpp;h=cd04d1b4af153a981973c75e7eb8ff642d8f7545;hb=d4b030f46c3a643e813cf31e3faa2b4f3662a160;hp=4c22ba3c01e70b01d68852f31f411799fce2f91f;hpb=1b23728908f5ec9beb08b2b70737c3903745fddc;p=libs%2Fgl.git diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 4c22ba3c..cd04d1b4 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -4,23 +4,27 @@ #include #include #include -#include "error.h" #include "light.h" #include "lighting.h" -#include "matrix.h" using namespace std; namespace Msp { namespace GL { -Lighting::Lighting(): - zenith_direction(0, 0, 1), - horizon_angle(Geometry::Angle::zero()) +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) @@ -29,24 +33,6 @@ void Lighting::set_ambient(const Color &a) shdata.uniform("ambient_color", ambient); } -void Lighting::set_sky_color(const Color &s) -{ - sky_color = s; - shdata.uniform("sky_color", sky_color); -} - -void Lighting::set_zenith_direction(const Vector3 &d) -{ - zenith_direction = d; - shdata.uniform("world_zenith_dir", zenith_direction); -} - -void Lighting::set_horizon_angle(const Geometry::Angle &a) -{ - horizon_angle = a; - shdata.uniform("horizon_limit", horizon_angle.radians()); -} - void Lighting::set_fog_color(const Color &c) { fog_color = c; @@ -77,34 +63,10 @@ void Lighting::detach(const Light &l) { auto i = find_member(lights, &l, &AttachedLight::light); if(i!=lights.end()) + { lights.erase(i); -} - -void Lighting::detach(unsigned i) -{ - if(i>=lights.size()) - return; - - detach(*lights[i].light); -} - -const Light *Lighting::get_attached_light(unsigned i) const -{ - return iupdate_shader_data(sd, i); + shdata.uniform(format("light_sources[%d].enabled", lights.size()), 0); + } } const ProgramData &Lighting::get_shader_data() const @@ -151,12 +113,6 @@ void Lighting::Loader::init_actions() add("fog_half_distance", &Loader::fog_half_distance); add("light", &Loader::light); add("light", &Loader::light_inline); - - // Deprecated - add("horizon_angle", &Loader::horizon_angle); - add("light", &Loader::light_inline_index); - add("sky_color", &Loader::sky_color); - add("zenith_direction", &Loader::zenith_direction); } void Lighting::Loader::ambient(float r, float g, float b) @@ -179,14 +135,6 @@ void Lighting::Loader::fog_half_distance(float d) obj.set_fog_half_distance(d); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Lighting::Loader::horizon_angle(float a) -{ - obj.set_horizon_angle(Geometry::Angle::from_degrees(a)); -} -#pragma GCC diagnostic pop - void Lighting::Loader::light(const string &name) { obj.attach(get_collection().get(name)); @@ -200,23 +148,5 @@ void Lighting::Loader::light_inline() obj.attach(*lgt.release()); } -void Lighting::Loader::light_inline_index(unsigned) -{ - light_inline(); -} - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Lighting::Loader::sky_color(float r, float g, float b) -{ - obj.set_sky_color(Color(r, g, b)); -} - -void Lighting::Loader::zenith_direction(float x, float y, float z) -{ - obj.set_zenith_direction(Vector3(x, y, z)); -} -#pragma GCC diagnostic pop - } // namespace GL } // namespace Msp