]> git.tdb.fi Git - libs/gl.git/commitdiff
Deprecate Renderer::escape() and replace it with end()
authorMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 16:59:36 +0000 (19:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 17:06:15 +0000 (20:06 +0300)
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.

source/pipeline.cpp
source/renderer.cpp
source/renderer.h

index 0546a4e847829f33844cf6236db2047816ba0b2f..fd638fb6ebbbbdd0a95a78caa57586d67b7660bf 100644 (file)
@@ -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])
        {
index 0207f9378324aaed15a22725fbaa5897bf666bff..06841fa7a9a42442b6265b36f2c04d928fed8845 100644 (file)
@@ -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);
index ccb23a22a709ff1f864e6179435c9ead36bb5db8..5d8f686e35806a419e4a46167fd75161666ed725 100644 (file)
@@ -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 &);