From: Mikko Rasa Date: Sun, 19 Oct 2014 16:59:36 +0000 (+0300) Subject: Deprecate Renderer::escape() and replace it with end() X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=58e3368ddb21de5c4bc6e208440de369fe4876f1;p=libs%2Fgl.git Deprecate Renderer::escape() and replace it with end() I never used escape() for much anything, and now it's causing problems on OpenGL ES by trying to apply state with no shader and consequently set system matrices. In the future I'll add a corresponding begin() call to allow persistent Renderers. --- diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 0546a4e8..fd638fb6 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -167,7 +167,7 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const renderer.render(*j->renderable, i->get_tag()); } - renderer.escape(); + renderer.end(); if(target[0]) { diff --git a/source/renderer.cpp b/source/renderer.cpp index 0207f937..06841fa7 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -47,21 +47,7 @@ Renderer::Renderer(const Camera *c): 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) @@ -161,6 +147,30 @@ void Renderer::escape() 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); diff --git a/source/renderer.h b/source/renderer.h index ccb23a22..5d8f686e 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -140,9 +140,13 @@ 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(); + /** 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 &);