Renderer::~Renderer()
{
- if(matrices_loaded)
- {
- if(camera)
- MatrixStack::projection().pop();
- MatrixStack::modelview().pop();
- }
-
- Mesh::unbind();
- Texturing::unbind();
- Texture::unbind_from(0);
- Material::unbind();
- Lighting::unbind();
- Program::unbind();
- Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
- WindingTest::unbind();
+ end();
}
void Renderer::set_texture(const Texture *t)
matrices_loaded = false;
}
+void Renderer::end()
+{
+ if(state_stack.size()>1)
+ throw invalid_operation("Renderer::end");
+
+ if(matrices_loaded)
+ {
+ if(camera)
+ MatrixStack::projection().pop();
+ MatrixStack::modelview().pop();
+ }
+
+ Mesh::unbind();
+ Texturing::unbind();
+ Texture::unbind_from(0);
+ Material::unbind();
+ Lighting::unbind();
+ Program::unbind();
+ Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
+ WindingTest::unbind();
+
+ *state = State();
+}
+
void Renderer::exclude(const Renderable &renderable)
{
excluded.insert(&renderable);
/** 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();
+ /** Ends rendering, unbinding all objects and resetting state. There must
+ be no unpopped state in the stack. */
+ void end();
+
void exclude(const Renderable &);
void include(const Renderable &);