]> git.tdb.fi Git - libs/gl.git/blobdiff - source/clipping.cpp
Require legacy features when binding plain clip planes
[libs/gl.git] / source / clipping.cpp
index add7bba68f698cd798511966226200361ee83240..487eeca638cbcfd7a33e1c04e086b124c47b7cbd 100644 (file)
@@ -59,7 +59,7 @@ void Clipping::bind(bool legacy) const
                static Require _req(MSP_legacy_features);
 
        const Clipping *old = current();
-       if(!set_current(this))
+       if(!set_current(this) && !(legacy && !bound_with_legacy))
                return;
 
        bound_with_legacy = legacy;
@@ -99,6 +99,22 @@ void Clipping::bind(bool legacy) const
 
 void Clipping::unbind()
 {
+       const Clipping *old = current();
+       if(!set_current(0))
+               return;
+
+       if(bound_with_legacy)
+       {
+               for(unsigned i=0; i<old->planes.size(); ++i)
+                       if(old->planes[i])
+                               ClipPlane::unbind_from(i);
+       }
+       else
+       {
+               for(unsigned i=0; i<old->planes.size(); ++i)
+                       if(old->planes[i])
+                               disable(GL_CLIP_PLANE0+i);
+       }
 }
 
 } // namespace GL