X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frenderer.h;h=a4c5ef03ca93ad316bb7af61723ac103456c657c;hb=b781d8d1d713e28ec21a66a9d78eb3fc01f327e5;hp=a3ddaa3bd28f3832ce2a21884384727c897ede5f;hpb=6d2e5c8e7ef79706adfce1b69695e3c8071c6ddb;p=libs%2Fgl.git diff --git a/source/renderer.h b/source/renderer.h index a3ddaa3b..a4c5ef03 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -13,6 +13,7 @@ namespace GL { class Batch; class Buffer; class Camera; +class Clipping; class Material; class Mesh; class Lighting; @@ -69,6 +70,8 @@ private: const Material *material; const Lighting *lighting; Matrix lighting_matrix; + const Clipping *clipping; + Matrix clipping_matrix; const Program *shprog; unsigned shdata_count; const Mesh *mesh; @@ -91,28 +94,48 @@ private: enum ChangeMask { - MATRIX = 1, + LEGACY_MATRIX = 1, + MODERN_MATRIX = 2, + MATRIX = LEGACY_MATRIX|MODERN_MATRIX, LIGHTING = 4, - SHADER_DATA = 8 + CLIPPING = 8, + SHADER_DATA = 16, + MATERIAL_SHDATA = 32, + STANDARD_SHDATA = 64 }; MtxStack mtx_stack; unsigned char changed; bool matrices_loaded; + unsigned shdata_applied; const Camera *camera; std::vector state_stack; State *state; ProgramData standard_shdata; std::vector shdata_stack; - const Buffer *element_buffer; std::set excluded; 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 *); + + /** Deprecated as unsafe. Use set_matrix() or transform() instead. */ MatrixStack &matrix_stack() { return mtx_stack; } + /** Replaces the Renderer's modelview matrix. */ + void set_matrix(const Matrix &); + + /** Applies a transform to the Renderer's modelview matrix. */ + void transform(const Matrix &); + + /** Returns the current modelview matrix. */ + const Matrix &get_matrix() const { return mtx_stack.top(); } + const Camera *get_camera() const { return camera; } void set_texture(const Texture *); @@ -121,6 +144,7 @@ public: void set_material(const Material *); 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 well, with the same semantics as add_shader_data. */ @@ -132,7 +156,6 @@ public: void add_shader_data(const ProgramData &data); void set_mesh(const Mesh *); - void set_element_buffer(const Buffer *); void set_winding_test(const WindingTest *); void set_reverse_winding(bool); @@ -148,8 +171,9 @@ public: Renderer. DEPRECATED. */ void escape(); - /** Ends rendering, unbinding all objects and resetting state. There must - be no unpopped state in the stack. */ + /** 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 &); @@ -160,6 +184,7 @@ public: private: void apply_state(); + void reset_state(); }; } // namespace GL