]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderer.h
Add begin() method to make Renderer reusable
[libs/gl.git] / source / renderer.h
index ccb23a22a709ff1f864e6179435c9ead36bb5db8..1f198dae7007b00db30d4c699f0832ce06d0cca1 100644 (file)
@@ -89,16 +89,24 @@ private:
                virtual void update();
        };
 
+       enum ChangeMask
+       {
+               LEGACY_MATRIX = 1,
+               MODERN_MATRIX = 2,
+               MATRIX = LEGACY_MATRIX|MODERN_MATRIX,
+               LIGHTING = 4,
+               SHADER_DATA = 8
+       };
+
        MtxStack mtx_stack;
-       bool mtx_changed;
+       unsigned char changed;
        bool matrices_loaded;
+       unsigned shdata_applied;
        const Camera *camera;
        std::vector<State> state_stack;
        State *state;
-       bool lighting_changed;
        ProgramData standard_shdata;
        std::vector<const ProgramData *> shdata_stack;
-       bool shdata_changed;
        const Buffer *element_buffer;
        std::set<const Renderable *> excluded;
 
@@ -106,6 +114,11 @@ public:
        Renderer(const Camera *);
        ~Renderer();
 
+       /** Resets all internal state and restarts rendering.  There must be no
+       unpopped state in the stack.  It is permissible to call begin() multiple
+       times without an intervening end(). */
+       void begin(const Camera *);
+
        MatrixStack &matrix_stack() { return mtx_stack; }
 
        const Camera *get_camera() const { return camera; }
@@ -140,9 +153,14 @@ public:
 
        /** Prepares for temporarily bypassing the Renderer by synchronizing the
        current state with GL.  No additional call is necessary to resume using the
-       Renderer. */
+       Renderer.  DEPRECATED. */
        void escape();
 
+       /** Unbinds all objects and resets related state.  There must be no unpopped
+       state in the stack.  Rendering with the same camera can be restarted without
+       an explicit begin() call. */
+       void end();
+
        void exclude(const Renderable &);
        void include(const Renderable &);
 
@@ -151,6 +169,7 @@ public:
 
 private:
        void apply_state();
+       void reset_state();
 };
 
 } // namespace GL