public:
MatrixStack();
- const Matrix &top();
+ const Matrix &top() const;
void load(const Matrix &);
void multiply(const Matrix &);
void push();
void pop();
private:
- void update();
+ virtual void update();
public:
MatrixStack &operator=(const Matrix &);
namespace GL {
Renderer::Renderer(const Camera *c):
+ mtx_stack(*this),
mtx_changed(false),
camera(c),
state_stack(1),
{
MatrixStack::projection().push();
camera->apply();
- mtx_stack = camera->get_matrix();
+ mtx_stack.load(camera->get_matrix());
}
else
- mtx_stack = MatrixStack::modelview().top();
+ mtx_stack.load(MatrixStack::modelview().top());
}
Renderer::~Renderer()
Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
}
-MatrixStack &Renderer::matrix_stack()
-{
- mtx_changed = true;
- return mtx_stack;
-}
-
void Renderer::set_texture(const Texture *t)
{
state->texture = t;
state_stack.pop_back();
state = &state_stack.back();
mtx_stack.pop();
+ mtx_changed = true;
}
void Renderer::escape()
shprog(0)
{ }
+
+Renderer::MtxStack::MtxStack(Renderer &r):
+ renderer(r)
+{ }
+
+void Renderer::MtxStack::update()
+{
+ renderer.mtx_changed = true;
+}
+
} // namespace GL
} // namespace Msp
State();
};
- MatrixStack mtx_stack;
+ class MtxStack: public MatrixStack
+ {
+ private:
+ Renderer &renderer;
+
+ public:
+ MtxStack(Renderer &);
+ private:
+ virtual void update();
+ };
+
+ MtxStack mtx_stack;
bool mtx_changed;
const Camera *camera;
std::list<State> state_stack;
Renderer(const Camera *);
~Renderer();
- MatrixStack &matrix_stack();
+ MatrixStack &matrix_stack() { return mtx_stack; }
const Camera *get_camera() const { return camera; }