From: Mikko Rasa Date: Thu, 12 Aug 2021 11:35:45 +0000 (+0300) Subject: Remove some deprecated stuff that's getting in the way X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5b652353d545a3190ea2d86ba82a87b2e3382a0d;p=libs%2Fgl.git Remove some deprecated stuff that's getting in the way --- diff --git a/source/materials/basicmaterial.cpp b/source/materials/basicmaterial.cpp index 30202a56..49a74764 100644 --- a/source/materials/basicmaterial.cpp +++ b/source/materials/basicmaterial.cpp @@ -41,19 +41,6 @@ void BasicMaterial::fill_program_info(string &module_name, map &spe spec_values["use_reflectivity_map"] = (reflectivity.texture!=0); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void BasicMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const -{ - attach_texture_to(diffuse.texture, texturing, tex_shdata, "diffuse_map"); - attach_texture_to(specular.texture, texturing, tex_shdata, "specular_map"); - attach_texture_to(normal.texture, texturing, tex_shdata, "normal_map"); - attach_texture_to(emission.texture, texturing, tex_shdata, "emission_map"); - attach_texture_to(shininess.texture, texturing, tex_shdata, "shininess_map"); - attach_texture_to(reflectivity.texture, texturing, tex_shdata, "reflectivity_map"); -} -#pragma GCC diagnostic pop - const Texture *BasicMaterial::get_texture(Tag tag) const { if(tag==texture_tags[0]) diff --git a/source/materials/basicmaterial.h b/source/materials/basicmaterial.h index bf4a1c1c..a5a8a43f 100644 --- a/source/materials/basicmaterial.h +++ b/source/materials/basicmaterial.h @@ -39,8 +39,6 @@ protected: virtual void fill_program_info(std::string &, std::map &) const; public: - DEPRECATED virtual void attach_textures_to(Texturing &, ProgramData &) const; - virtual const Tag *get_texture_tags() const { return texture_tags; } virtual const Texture *get_texture(Tag) const; diff --git a/source/materials/material.cpp b/source/materials/material.cpp index b2ee973a..2d7e4487 100644 --- a/source/materials/material.cpp +++ b/source/materials/material.cpp @@ -4,7 +4,6 @@ #include "gl.h" #include "pbrmaterial.h" #include "resources.h" -#include "texturing.h" #include "uniform.h" #include "unlitmaterial.h" @@ -47,29 +46,6 @@ const Program *Material::create_compatible_shader(const map &extra_ return shprog; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Material::attach_texture_to(const Texture *tex, Texturing &texturing, ProgramData &tex_shdata, const string &name) const -{ - if(!tex) - return; - - int unit = -1; - - if(const Uniform *uni = tex_shdata.find_uniform(name)) - if(const Uniform1i *uni_int = dynamic_cast(uni)) - unit = uni_int->get(); - - if(unit<0) - unit = texturing.find_free_unit(name); - if(unit<0) - throw runtime_error("no free texunit"); - - texturing.attach(unit, *tex, sampler); - tex_shdata.uniform(name, unit); -} -#pragma GCC diagnostic pop - void Material::set_debug_name(const string &name) { #ifdef DEBUG diff --git a/source/materials/material.h b/source/materials/material.h index a5ee59e5..43da2542 100644 --- a/source/materials/material.h +++ b/source/materials/material.h @@ -11,8 +11,6 @@ namespace Msp { namespace GL { -class Texturing; - class Material { private: @@ -105,11 +103,6 @@ public: /** Returns the uniforms for the material. */ const ProgramData &get_shader_data() const { return shdata; } -protected: - DEPRECATED void attach_texture_to(const Texture *, Texturing &, ProgramData &, const std::string &) const; -public: - DEPRECATED virtual void attach_textures_to(Texturing &, ProgramData &) const = 0; - virtual const Tag *get_texture_tags() const = 0; virtual const Texture *get_texture(Tag) const = 0; const Sampler *get_sampler() const { return sampler; } diff --git a/source/materials/pbrmaterial.cpp b/source/materials/pbrmaterial.cpp index 76683e9f..08221816 100644 --- a/source/materials/pbrmaterial.cpp +++ b/source/materials/pbrmaterial.cpp @@ -74,19 +74,6 @@ void PbrMaterial::fill_program_info(string &module_name, map &spec_ spec_values["use_emission_map"] = (emission.texture!=0); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void PbrMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const -{ - attach_texture_to(base_color.texture, texturing, tex_shdata, "base_color_map"); - attach_texture_to(metalness.texture, texturing, tex_shdata, "metalness_map"); - attach_texture_to(roughness.texture, texturing, tex_shdata, "roughness_map"); - attach_texture_to(normal.texture, texturing, tex_shdata, "normal_map"); - attach_texture_to(occlusion.texture, texturing, tex_shdata, "occlusion_map"); - attach_texture_to(emission.texture, texturing, tex_shdata, "emission_map"); -} -#pragma GCC diagnostic pop - const Texture *PbrMaterial::get_texture(Tag tag) const { if(tag==texture_tags[0]) diff --git a/source/materials/pbrmaterial.h b/source/materials/pbrmaterial.h index 7c0d5459..dadda9b5 100644 --- a/source/materials/pbrmaterial.h +++ b/source/materials/pbrmaterial.h @@ -45,8 +45,6 @@ protected: virtual void fill_program_info(std::string &, std::map &) const; public: - DEPRECATED virtual void attach_textures_to(Texturing &, ProgramData &) const; - virtual const Tag *get_texture_tags() const { return texture_tags; } virtual const Texture *get_texture(Tag) const; diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 4ab72b56..475f3ed8 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -9,7 +9,6 @@ #include "renderer.h" #include "texture.h" #include "texture2d.h" -#include "texturing.h" #include "uniform.h" using namespace std; diff --git a/source/materials/renderpass.h b/source/materials/renderpass.h index d149a7d0..d5587c25 100644 --- a/source/materials/renderpass.h +++ b/source/materials/renderpass.h @@ -13,7 +13,6 @@ class ProgramData; class Renderer; class Sampler; class Texture; -class Texturing; /** Encapsulates the data that determines the appearance of a rendered surface. @@ -106,7 +105,6 @@ public: void set_texture(Tag, const Texture *, const Sampler * = 0); Tag get_texture_tag(const std::string &) const; DEPRECATED void set_texture(unsigned, const Texture *, const Sampler * = 0); - DEPRECATED const Texturing *get_texturing() const { return 0; } DEPRECATED int get_texture_index(const std::string &) const; void set_back_faces(bool); bool get_back_faces() const { return back_faces; } diff --git a/source/materials/unlitmaterial.cpp b/source/materials/unlitmaterial.cpp index 38dbd3a3..21f2b2f3 100644 --- a/source/materials/unlitmaterial.cpp +++ b/source/materials/unlitmaterial.cpp @@ -25,14 +25,6 @@ void UnlitMaterial::fill_program_info(string &module_name, map &spe spec_values["use_vertex_color"] = vertex_color; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void UnlitMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const -{ - attach_texture_to(texture, texturing, tex_shdata, "color_tex"); -} -#pragma GCC diagnostic pop - const Texture *UnlitMaterial::get_texture(Tag tag) const { if(tag==texture_tags[0]) diff --git a/source/materials/unlitmaterial.h b/source/materials/unlitmaterial.h index 442348da..dc027f1f 100644 --- a/source/materials/unlitmaterial.h +++ b/source/materials/unlitmaterial.h @@ -38,11 +38,6 @@ protected: virtual void fill_program_info(std::string &, std::map &) const; public: -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - DEPRECATED virtual void attach_textures_to(Texturing &, ProgramData &) const; -#pragma GCC diagnostic pop - virtual const Tag *get_texture_tags() const { return texture_tags; } virtual const Texture *get_texture(Tag) const; diff --git a/source/render/instancescene.cpp b/source/render/instancescene.cpp deleted file mode 100644 index c1f10979..00000000 --- a/source/render/instancescene.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "object.h" -#include "objectinstance.h" -#include "instancescene.h" -#include "renderer.h" - -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -namespace Msp { -namespace GL { - -void InstanceScene::add(Renderable &r) -{ - renderables[r.get_instance_key()].insert(&r); -} - -void InstanceScene::remove(Renderable &r) -{ - InstanceMap::iterator i = renderables.find(r.get_instance_key()); - if(i!=renderables.end()) - { - i->second.erase(&r); - if(i->second.empty()) - renderables.erase(i); - } -} - -void InstanceScene::setup_frame(Renderer &renderer) -{ - for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) - for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j) - (*j)->setup_frame(renderer); -} - -void InstanceScene::finish_frame() -{ - for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) - for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j) - (*j)->finish_frame(); -} - -void InstanceScene::render(Renderer &renderer, Tag tag) const -{ - if(setup_frustum(renderer)) - { - for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) - for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j) - if(!frustum_cull(**j)) - renderer.render(**j, tag); - } - else - { - for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) - for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j) - renderer.render(**j, tag); - } -} - -} // namespace GL -} // namespace Msp diff --git a/source/render/instancescene.h b/source/render/instancescene.h deleted file mode 100644 index ae9b637b..00000000 --- a/source/render/instancescene.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MSP_GL_INSTANCESCENE_H_ -#define MSP_GL_INSTANCESCENE_H_ - -#include -#include -#include -#include -#include "scene.h" - -namespace Msp { -namespace GL { - -/** -A Scene optimized for rendering instanced Renderables, such as ObjectInstances. -All Renderables with the same instance key are rendered consecutively; within -the same key rendering order is unspecified. -*/ -class DEPRECATED InstanceScene: public Scene -{ -private: - typedef std::set RenderableSet; - typedef std::map InstanceMap; - - InstanceMap renderables; - -public: - virtual void add(Renderable &); - virtual void remove(Renderable &); - - virtual void setup_frame(Renderer &); - virtual void finish_frame(); - - virtual void render(Renderer &, Tag tag = Tag()) const; -}; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/render/object.cpp b/source/render/object.cpp index caad3a07..38d2e6f2 100644 --- a/source/render/object.cpp +++ b/source/render/object.cpp @@ -11,7 +11,6 @@ #include "renderer.h" #include "resourcemanager.h" #include "technique.h" -#include "texturing.h" using namespace std; diff --git a/source/render/objectinstance.h b/source/render/objectinstance.h index c5358b06..b1501a7b 100644 --- a/source/render/objectinstance.h +++ b/source/render/objectinstance.h @@ -32,7 +32,6 @@ public: ObjectInstance(const Object &); const Object &get_object() const { return object; } - DEPRECATED virtual IntPtr get_instance_key() const { return reinterpret_cast(&object); } virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return object.get_bounding_sphere(); } diff --git a/source/render/renderable.h b/source/render/renderable.h index 30386392..4175dd81 100644 --- a/source/render/renderable.h +++ b/source/render/renderable.h @@ -3,7 +3,6 @@ #include #include -#include #include #include "tag.h" @@ -34,10 +33,6 @@ protected: public: virtual ~Renderable() { } - /** Returns a key used for grouping Renderables in an InstanceScene. The - returned value is treated as opaque. */ - DEPRECATED virtual IntPtr get_instance_key() const { return 0; } - /** Returns the model matrix of the Renderable. Null is returned if no such matrix exists. The matrix should be in world space for some effects to work correctly. */ diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 1d43a939..d86b7804 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -12,7 +12,6 @@ #include "renderer.h" #include "sampler.h" #include "texture.h" -#include "texturing.h" #include "texunit.h" #include "vertexarray.h" #include "vertexsetup.h" @@ -23,22 +22,7 @@ using namespace std; namespace Msp { namespace GL { -Renderer::Renderer(): - default_camera(0) -{ - init(); -} - -Renderer::Renderer(const Camera *c): - default_camera(c) -{ - init(); - - if(c) - set_camera(*c); -} - -void Renderer::init() +Renderer::Renderer() { state_stack.reserve(16); state_stack.push_back(State()); @@ -72,16 +56,11 @@ void Renderer::transform(const Matrix &matrix) } void Renderer::set_texture(Tag tag, const Texture *tex, const Sampler *samp) -{ - set_texture(tag, -1, tex, samp); -} - -void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler *samp) { if(texture_stack.size()>state->texture_count) { BoundTexture &bt = texture_stack[state->texture_count]; - if((!tag.id || bt.tag==tag) && (unit<0 || bt.unit==unit) && bt.texture==tex && bt.sampler==samp) + if(bt.tag==tag && bt.texture==tex && bt.sampler==samp) { ++state->texture_count; return; @@ -91,7 +70,7 @@ void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler } for(vector::iterator i=texture_stack.end(); i!=texture_stack.begin(); ) - if((--i)->tag==tag && i->unit==unit) + if((--i)->tag==tag) { i->replaced = texture_stack.size(); break; @@ -100,17 +79,11 @@ void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler texture_stack.push_back(BoundTexture()); BoundTexture &bound_tex = texture_stack.back(); bound_tex.tag = tag; - bound_tex.unit = unit; bound_tex.texture = tex; bound_tex.sampler = samp; state->texture_count = texture_stack.size(); } -void Renderer::set_texture(const Texture *t, const Sampler *s) -{ - set_texture(Tag(), 0, t, s); -} - void Renderer::flush_textures() { for(unsigned i=0; itexture_count, texture_stack.end()); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Renderer::set_texturing(const Texturing *t) -{ - if(t) - { - unsigned n_units = TexUnit::get_n_units(); - for(unsigned i=0; iget_attached_texture(i)) - set_texture(Tag(), i, tex, t->get_attached_sampler(i)); - } -} -#pragma GCC diagnostic pop - -unsigned Renderer::allocate_effect_texunit() -{ - return --state->lowest_effect_texunit; -} - void Renderer::set_material(const Material *m) { if(m) @@ -239,8 +193,6 @@ void Renderer::end() throw invalid_operation("Renderer::end"); *state = State(); - if(default_camera) - set_camera(*default_camera); shdata_stack.clear(); excluded.clear(); @@ -300,7 +252,7 @@ void Renderer::apply_state() for(vector::const_iterator i=texture_stack.begin(); i!=texture_stack.end(); ++i) { - int unit = (i->tag.id ? state->shprog->get_uniform_binding(i->tag) : i->unit); + int unit = state->shprog->get_uniform_binding(i->tag); if(unit>=0) { if(i->texture) diff --git a/source/render/renderer.h b/source/render/renderer.h index 50254cdf..b5cbe5bc 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -21,7 +21,6 @@ class Program; class Renderable; class Sampler; class Texture; -class Texturing; class VertexSetup; class WindingTest; @@ -106,7 +105,6 @@ private: SHADER_DATA = 16 }; - const Camera *default_camera; unsigned char changed; std::vector state_stack; State *state; @@ -117,10 +115,6 @@ private: public: Renderer(); - DEPRECATED Renderer(const Camera *); -private: - void init(); -public: ~Renderer(); /** Sets the camera to render from. The model matrix is reset to identity. */ @@ -139,15 +133,8 @@ public: void set_texture(Tag, const Texture *, const Sampler * = 0); private: - void set_texture(Tag, int, const Texture *, const Sampler *); void flush_textures(); public: -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - DEPRECATED void set_texture(const Texture *, const Sampler * = 0); - DEPRECATED void set_texturing(const Texturing *); - DEPRECATED unsigned allocate_effect_texunit(); -#pragma GCC diagnostic pop DEPRECATED void set_material(const Material *); DEPRECATED void set_lighting(const Lighting *); diff --git a/source/render/texturing.cpp b/source/render/texturing.cpp deleted file mode 100644 index 341cdb79..00000000 --- a/source/render/texturing.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include -#include "texture.h" -#include "texturing.h" -#include "texunit.h" - -using namespace std; - -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -namespace Msp { -namespace GL { - -Texturing::~Texturing() -{ - if(current()==this) - unbind(); -} - -int Texturing::find_free_unit(const string &name_hint) const -{ - unsigned max_unit = TexUnit::get_n_units(); - // Leave some space for effect textures - max_unit -= min(max_unit/4, 8U); - unsigned initial_unit = (name_hint.empty() ? 0 : hash32(name_hint)%max_unit); - unsigned unit = initial_unit; - while(get_attached_texture(unit) || get_attached_sampler(unit)) - { - unit = (unit+1)%max_unit; - if(unit==initial_unit) - return -1; - } - - return unit; -} - -void Texturing::attach(unsigned attch, const Texture &tex, const Sampler *samp) -{ - set_attachment(attch, &tex, samp); -} - -void Texturing::attach(unsigned attch, const Sampler &samp) -{ - set_attachment(attch, 0, &samp); -} - -void Texturing::detach(unsigned attch) -{ - set_attachment(attch, 0, 0); -} - -void Texturing::set_attachment(unsigned unit, const Texture *tex, const Sampler *samp) -{ - if(unit>=TexUnit::get_n_units()) - throw out_of_range("Texturing::set_attachment"); - - if(tex || samp) - { - vector::iterator i; - for(i=attachments.begin(); (i!=attachments.end() && i->unit<=unit); ++i) - if(i->unit==unit) - { - i->texture = tex; - i->sampler = samp; - if(current()==this) - bind_attachment(*i); - return; - } - - attachments.insert(i, Attachment(unit, tex, samp)); - if(current()==this) - tex->bind_to(unit); - } - else - { - for(vector::iterator i=attachments.begin(); (i!=attachments.end() && i->unit<=unit); ++i) - if(i->unit==unit) - { - attachments.erase(i); - if(current()==this) - unbind_attachment(unit); - return; - } - } -} - -const Texture *Texturing::get_attached_texture(unsigned unit) const -{ - for(vector::const_iterator i=attachments.begin(); (i!=attachments.end() && i->unit<=unit); ++i) - if(i->unit==unit) - return i->texture; - return 0; -} - -const Sampler *Texturing::get_attached_sampler(unsigned unit) const -{ - for(vector::const_iterator i=attachments.begin(); (i!=attachments.end() && i->unit<=unit); ++i) - if(i->unit==unit) - return i->sampler; - return 0; -} - -void Texturing::bind() const -{ - const Texturing *old = current(); - if(set_current(this)) - { - if(old) - { - vector::const_iterator i = attachments.begin(); - vector::const_iterator j = old->attachments.begin(); - while(i!=attachments.end() || j!=old->attachments.end()) - { - if(i!=attachments.end() && (j==old->attachments.end() || i->unit<=j->unit)) - { - bind_attachment(*i); - if(j!=old->attachments.end() && j->unit==i->unit) - ++j; - ++i; - } - else - { - unbind_attachment(j->unit); - ++j; - } - } - } - else - { - for(vector::const_iterator i=attachments.begin(); i!=attachments.end(); ++i) - bind_attachment(*i); - } - } -} - -void Texturing::bind_attachment(const Attachment &attch) const -{ - if(attch.sampler) - attch.sampler->bind_to(attch.unit); - else - Sampler::unbind_from(attch.unit); - if(attch.texture) - attch.texture->bind_to(attch.unit); - else - Texture::unbind_from(attch.unit); -} - -void Texturing::unbind() -{ - const Texturing *old = current(); - if(set_current(0)) - { - for(vector::const_iterator i=old->attachments.begin(); i!=old->attachments.end(); ++i) - unbind_attachment(i->unit); - } -} - -void Texturing::unbind_attachment(unsigned unit) -{ - Texture::unbind_from(unit); - Sampler::unbind_from(unit); -} - - -Texturing::Attachment::Attachment(unsigned u, const Texture *t, const Sampler *s): - unit(u), - texture(t), - sampler(s) -{ } - -} // namespace GL -} // namespace Msp; diff --git a/source/render/texturing.h b/source/render/texturing.h deleted file mode 100644 index 44189c90..00000000 --- a/source/render/texturing.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef MSP_GL_TEXTURING_H_ -#define MSP_GL_TEXTURING_H_ - -#include -#include "bindable.h" - -namespace Msp { -namespace GL { - -class Texture; - -class DEPRECATED Texturing: public Bindable -{ -private: - struct Attachment - { - unsigned unit; - const Texture *texture; - const Sampler *sampler; - - Attachment(unsigned, const Texture *, const Sampler *); - }; - - std::vector attachments; - -public: - ~Texturing(); - - int find_free_unit(const std::string & = std::string()) const; - void attach(unsigned, const Texture &, const Sampler * = 0); - void attach(unsigned, const Sampler &); - void detach(unsigned); -private: - void set_attachment(unsigned, const Texture *, const Sampler *); -public: - const Texture *get_attached_texture(unsigned) const; - const Sampler *get_attached_sampler(unsigned) const; - - void bind() const; - - static void unbind(); - -private: - void bind_attachment(const Attachment &) const; - static void unbind_attachment(unsigned); -}; - -} // namespace GL -} // namespace Msp; - -#endif