From: Mikko Rasa Date: Sat, 2 Oct 2021 11:05:00 +0000 (+0300) Subject: Remove deprecated interfaces from material and lighting code X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5008778dbb1840bf7c6d479800d2b932f8386fb2;p=libs%2Fgl.git Remove deprecated interfaces from material and lighting code --- diff --git a/shaderlib/msp_interface.glsl b/shaderlib/msp_interface.glsl index 860b0c79..6c229da0 100644 --- a/shaderlib/msp_interface.glsl +++ b/shaderlib/msp_interface.glsl @@ -24,9 +24,6 @@ uniform Lighting // Declared as an array for compatibility reasons LightSourceParameters light_sources[1]; vec4 ambient_color; - vec4 sky_color; - vec3 world_zenith_dir; - float horizon_limit; vec4 fog_color; float fog_density; }; diff --git a/source/materials/light.cpp b/source/materials/light.cpp index 8f546172..7c78b393 100644 --- a/source/materials/light.cpp +++ b/source/materials/light.cpp @@ -129,10 +129,6 @@ Light::Loader::Loader(Light &l): add("spot_direction", &Loader::spot_direction); add("spot_exponent", &Loader::spot_exponent); add("spot_cutoff", &Loader::spot_cutoff); - - // Deprecated - add("diffuse", &Loader::color); - add("specular"); } void Light::Loader::attenuation(float c, float l, float q) diff --git a/source/materials/light.h b/source/materials/light.h index a6ffd16e..05a05aa9 100644 --- a/source/materials/light.h +++ b/source/materials/light.h @@ -71,11 +71,6 @@ public: const Color &get_color() const { return color; } const Color &get_transmittance() const { return transmittance; } - DEPRECATED void set_diffuse(const Color &c) { set_color(c); } - DEPRECATED void set_specular(const Color &) { } - DEPRECATED const Color &get_diffuse() const { return color; } - DEPRECATED const Color &get_specular() const { return color; } - /** Sets the postion and orientation of the Light from a matrix. Negative Z axis is used as the spot direction, other axes are ignored. */ virtual void set_matrix(const Matrix &); diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 0fc26ab5..20c812fe 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -12,9 +12,7 @@ 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)); @@ -27,24 +25,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; @@ -78,33 +58,6 @@ void Lighting::detach(const Light &l) 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); -} - const ProgramData &Lighting::get_shader_data() const { for(unsigned i=0; i::from_degrees(a)); -} -#pragma GCC diagnostic pop - void Lighting::Loader::light(const string &name) { obj.attach(get_collection().get(name)); @@ -198,23 +137,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 diff --git a/source/materials/lighting.h b/source/materials/lighting.h index 92a4bcf8..d4e6b594 100644 --- a/source/materials/lighting.h +++ b/source/materials/lighting.h @@ -34,12 +34,8 @@ public: void fog_color(float, float, float); void fog_density(float); void fog_half_distance(float); - void horizon_angle(float); void light(const std::string &); void light_inline(); - void light_inline_index(unsigned); - void sky_color(float, float, float); - void zenith_direction(float, float, float); }; private: @@ -52,9 +48,6 @@ private: }; Color ambient; - Color sky_color; - Vector3 zenith_direction; - Geometry::Angle horizon_angle; Color fog_color; float fog_density; std::vector lights; @@ -68,17 +61,6 @@ public: const Color &get_ambient() const { return ambient; } - /** Sets the color of the sky at zenith. Has no effect without shaders. */ - DEPRECATED void set_sky_color(const Color &); - - /** Sets the direction of the zenith. Defaults to positive Z axis. Has no - effect without shaders. */ - DEPRECATED void set_zenith_direction(const Vector3 &); - - /** Sets the angle where skylight cuts off, counted from the true horizon. - Has no effect without shaders. */ - DEPRECATED void set_horizon_angle(const Geometry::Angle &); - /** Sets the fog color, which is blended into distant surfaces. */ void set_fog_color(const Color &); @@ -96,17 +78,6 @@ public: /** Detaches a light source. If the light was not attached, does nothing. */ void detach(const Light &); - DEPRECATED void attach(unsigned, const Light &l) { attach(l); } - DEPRECATED void detach(unsigned); - - /** Returns an attached light. If no light is attached at that index, null - is returned. */ - DEPRECATED const Light *get_attached_light(unsigned) const; - - /** Updates a ProgramData object with the uniforms for the Lighting, - including all attached light sources. A view matrix must be passed in. */ - DEPRECATED void update_shader_data(ProgramData &, const Matrix &) const; - const ProgramData &get_shader_data() const; void set_debug_name(const std::string &); diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 499a521f..a055f478 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "error.h" #include "renderpass.h" @@ -163,17 +162,6 @@ void RenderPass::Loader::finish() obj.maybe_create_material_shader(); } -// Temporary compatibility feature -string RenderPass::Loader::get_shader_name(const string &n) -{ - if(n.size()>=5 && !n.compare(n.size()-5, 5, ".glsl")) - { - IO::print(IO::cerr, "Warning: Loading module '%s' as shader is deprecated\n", n); - return n+".shader"; - } - return n; -} - void RenderPass::Loader::material_inline() { Material::GenericLoader ldr(coll); @@ -192,7 +180,7 @@ void RenderPass::Loader::material(const string &name) void RenderPass::Loader::shader(const string &n) { - obj.shprog = &get_collection().get(get_shader_name(n)); + obj.shprog = &get_collection().get(n); obj.shprog_from_material = false; if(obj.shdata) obj.shdata = new ProgramData(*obj.shdata, obj.shprog); diff --git a/source/materials/renderpass.h b/source/materials/renderpass.h index c810e2c7..ae9e34b8 100644 --- a/source/materials/renderpass.h +++ b/source/materials/renderpass.h @@ -41,8 +41,6 @@ public: private: virtual void finish(); - static std::string get_shader_name(const std::string &); - void material_inline(); void material(const std::string &); void shader(const std::string &); diff --git a/source/materials/technique.cpp b/source/materials/technique.cpp index 21cb3a32..122eaf73 100644 --- a/source/materials/technique.cpp +++ b/source/materials/technique.cpp @@ -92,14 +92,6 @@ bool Technique::replace_uniforms(const ProgramData &shdata) return replaced; } -bool Technique::has_shaders() const -{ - for(const auto &kvp: passes) - if(kvp.second.get_shader_program()) - return true; - return false; -} - void Technique::set_debug_name(const string &name) { #ifdef DEBUG diff --git a/source/materials/technique.h b/source/materials/technique.h index 419c6765..c2b69bf7 100644 --- a/source/materials/technique.h +++ b/source/materials/technique.h @@ -61,7 +61,6 @@ public: bool replace_texture(const std::string &, const Texture &); bool replace_material(const std::string &, const Material &); bool replace_uniforms(const ProgramData &); - DEPRECATED bool has_shaders() const; void set_debug_name(const std::string &); };