]> git.tdb.fi Git - libs/gl.git/commitdiff
Deprecated setting Material or Lighting on Renderer
authorMikko Rasa <tdb@tdb.fi>
Sat, 7 Aug 2021 12:07:44 +0000 (15:07 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 7 Aug 2021 12:07:44 +0000 (15:07 +0300)
Those no longer have any special state of their own and can be set as
ProgramData instead.

source/materials/renderpass.cpp
source/render/renderer.cpp
source/render/renderer.h
source/render/sequence.cpp

index 62056ff9f56c63f103edb920ee8b546c7b13fe91..4ab72b568d32a9704c1c56ff90dab503e7b8a297 100644 (file)
@@ -139,8 +139,9 @@ void RenderPass::apply(Renderer &renderer) const
 {
        for(vector<TextureSlot>::const_iterator i=textures.begin(); i!=textures.end(); ++i)
                renderer.set_texture(i->tag, i->texture, i->sampler);
-       renderer.set_material(material);
        renderer.set_shader_program(shprog, shdata.get());
+       if(material)
+               renderer.add_shader_data(material->get_shader_data());
        renderer.set_reverse_winding(back_faces);
 }
 
index 2da4bd78f4969a016ee71099ac2655567ca051f0..7389298a0ebe3c8db298ab72154a83d4aa949c7a 100644 (file)
@@ -147,14 +147,14 @@ unsigned Renderer::allocate_effect_texunit()
 
 void Renderer::set_material(const Material *m)
 {
-       state->material = m;
-       changed |= MATERIAL_SHDATA;
+       if(m)
+               add_shader_data(m->get_shader_data());
 }
 
 void Renderer::set_lighting(const Lighting *l)
 {
-       state->lighting = l;
-       changed |= LIGHTING_SHDATA;
+       if(l)
+               add_shader_data(l->get_shader_data());
 }
 
 void Renderer::set_clipping(const Clipping *c)
@@ -226,7 +226,6 @@ void Renderer::pop_state()
                throw stack_underflow("Renderer::pop_state");
 
        const Camera *old_camera = state->camera;
-       const Lighting *old_lighting = state->lighting;
        const Clipping *old_clipping = state->clipping;
        state_stack.pop_back();
        state = &state_stack.back();
@@ -234,8 +233,6 @@ void Renderer::pop_state()
        bool camera_changed = (state->camera!=old_camera);
        if(camera_changed)
                changed |= CAMERA_SHDATA;
-       if(state->lighting!=old_lighting)
-               changed |= LIGHTING_SHDATA;
        if(state->clipping!=old_clipping)
                changed |= CLIPPING_SHDATA;
 }
@@ -341,18 +338,6 @@ void Renderer::apply_state()
                changed &= ~CAMERA_SHDATA;
        }
 
-       if(state->material && ((changed&MATERIAL_SHDATA) || shprog_changed))
-       {
-               state->material->get_shader_data().apply();
-               changed &= ~MATERIAL_SHDATA;
-       }
-
-       if(state->lighting && ((changed&LIGHTING_SHDATA) || shprog_changed))
-       {
-               state->lighting->get_shader_data().apply();
-               changed &= ~LIGHTING_SHDATA;
-       }
-
        if(state->clipping && ((changed&CLIPPING_SHDATA) || shprog_changed))
        {
                state->clipping->get_shader_data().apply();
@@ -417,8 +402,6 @@ Renderer::State::State():
        camera(0),
        texture_count(0),
        lowest_effect_texunit(TexUnit::get_n_units()),
-       material(0),
-       lighting(0),
        clipping(0),
        shprog(0),
        shdata_count(0),
index 197cf95a5c6b09090adc6ccd5e4505c2a1f44617..69474d4034b03b63bb8b8b20553dc2e91e7e0401 100644 (file)
@@ -89,8 +89,6 @@ private:
                Matrix model_matrix;
                unsigned texture_count;
                unsigned lowest_effect_texunit;
-               const Material *material;
-               const Lighting *lighting;
                const Clipping *clipping;
                const Program *shprog;
                unsigned shdata_count;
@@ -106,10 +104,8 @@ private:
        {
                MATRIX = 2,
                SHADER_DATA = 16,
-               MATERIAL_SHDATA = 32,
                STANDARD_SHDATA = 64,
                CAMERA_SHDATA = 128,
-               LIGHTING_SHDATA = 256,
                CLIPPING_SHDATA = 512
        };
 
@@ -155,9 +151,9 @@ public:
        DEPRECATED void set_texturing(const Texturing *);
        DEPRECATED unsigned allocate_effect_texunit();
 #pragma GCC diagnostic pop
-       void set_material(const Material *);
+       DEPRECATED void set_material(const Material *);
 
-       void set_lighting(const Lighting *);
+       DEPRECATED void set_lighting(const Lighting *);
        void set_clipping(const Clipping *);
 
        /** Sets the shader program to use.  An initial set of data can be set as
index 05cbafff08d66b406242da77228d83d0252d037b..9161c75146cc7552ac5363e21d69700a7ff5b564 100644 (file)
@@ -185,7 +185,8 @@ void Sequence::render(Renderer &renderer, Tag tag) const
                else
                        Blend::unbind();
 
-               renderer.set_lighting(i->get_lighting());
+               if (const Lighting *lighting = i->get_lighting())
+                       renderer.add_shader_data(lighting->get_shader_data());
                renderer.set_clipping(i->get_clipping());
 
                if(const Renderable *renderable = i->get_renderable())