]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/renderer.h
Overhaul texture management in rendering classes
[libs/gl.git] / source / render / renderer.h
index f8d297289085557c31cfc866ed1e1b2b2d5d952d..603866073c7e81f6edac092d6db169d7c7a98051 100644 (file)
@@ -64,13 +64,22 @@ public:
        };
 
 private:
+       struct BoundTexture
+       {
+               Tag tag;
+               mutable int unit;
+               const Texture *texture;
+               const Sampler *sampler;
+               int replaced;
+
+               BoundTexture();
+       };
+
        struct State
        {
                const Camera *camera;
                Matrix modelview_matrix;
-               const Texture *texture;
-               const Sampler *sampler;
-               const Texturing *texturing;
+               unsigned texture_count;
                unsigned lowest_effect_texunit;
                const Material *material;
                const Lighting *lighting;
@@ -99,6 +108,7 @@ private:
        unsigned char changed;
        std::vector<State> state_stack;
        State *state;
+       std::vector<BoundTexture> texture_stack;
        ProgramData standard_shdata;
        std::vector<const ProgramData *> shdata_stack;
        std::set<const Renderable *> excluded;
@@ -126,9 +136,17 @@ public:
        /** Returns the current modelview matrix. */
        const Matrix &get_matrix() const { return state->modelview_matrix; }
 
-       void set_texture(const Texture *, const Sampler * = 0);
-       void set_texturing(const Texturing *);
-       unsigned allocate_effect_texunit();
+       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
        void set_material(const Material *);
 
        void set_lighting(const Lighting *);