3 This file is part of libmspgl
4 Copyright © 2011 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_RENDERER_H_
9 #define MSP_GL_RENDERER_H_
29 A class for supervising the rendering process. While many Renderables (in
30 particular, Objects and Scenes) can by rendered without a Renderer, using one
31 will often be more efficient. This is especially true for ObjectInstances.
33 The Renderer works by deferring GL state changes until something is actually
34 being drawn. This avoids many unnecessary GL calls. */
44 Push(Renderer &r): renderer(r) { renderer.push_state(); }
45 ~Push() { renderer.pop_state(); }
51 const Texture *texture;
52 const Texturing *texturing;
53 const Material *material;
54 const Program *shprog;
55 std::vector<const ProgramData *> shdata;
56 const WindingTest *winding_test;
61 class MtxStack: public MatrixStack
69 virtual void update();
75 std::list<State> state_stack;
77 const VertexArray *vertex_array;
78 bool vertex_array_changed;
79 const Buffer *element_buffer;
82 Renderer(const Camera *);
85 MatrixStack &matrix_stack() { return mtx_stack; }
87 const Camera *get_camera() const { return camera; }
89 void set_texture(const Texture *);
90 void set_texturing(const Texturing *);
91 void set_material(const Material *);
92 void set_shader(const Program *, const ProgramData *);
93 void add_shader_data(const ProgramData *);
94 void set_vertex_array(const VertexArray *);
95 void set_element_buffer(const Buffer *);
96 void set_winding_test(const WindingTest *);
101 /** Prepares for temporarily bypassing the Renderer. */
104 void draw(const Batch &);