]> git.tdb.fi Git - libs/gl.git/blobdiff - source/clipping.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / clipping.cpp
index 430a7b6fd05918b43c62204b18859bdd47a828f0..3bdeee3ca8b3367624504f9815338f1810c4dcb9 100644 (file)
@@ -1,7 +1,6 @@
-#include <msp/gl/extensions/msp_legacy_features.h>
+#include <msp/gl/extensions/msp_clipping.h>
 #include "clipping.h"
 #include "clipplane.h"
-#include "clipunit.h"
 #include "matrix.h"
 #include "misc.h"
 
@@ -10,11 +9,16 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-bool Clipping::bound_with_legacy = false;
+unsigned Clipping::get_n_attach_points()
+{
+       static Require _req(MSP_clipping);
+       static int count = get_i(GL_MAX_CLIP_PLANES);
+       return count;
+}
 
 void Clipping::attach(unsigned i, const ClipPlane &p)
 {
-       if(i>=ClipUnit::get_n_units())
+       if(i>=get_n_attach_points())
                throw out_of_range("Clipping::attach");
 
        if(i>=planes.size())
@@ -22,12 +26,7 @@ void Clipping::attach(unsigned i, const ClipPlane &p)
 
        planes[i] = &p;
        if(current()==this)
-       {
-               if(bound_with_legacy)
-                       p.bind_to(i);
-               else
-                       glEnable(GL_CLIP_PLANE0+i);
-       }
+               glEnable(GL_CLIP_PLANE0+i);
 }
 
 void Clipping::detach(unsigned i)
@@ -37,12 +36,7 @@ void Clipping::detach(unsigned i)
 
        planes[i] = 0;
        if(current()==this)
-       {
-               if(bound_with_legacy)
-                       ClipPlane::unbind_from(i);
-               else
-                       disable(GL_CLIP_PLANE0+i);
-       }
+               disable(GL_CLIP_PLANE0+i);
 }
 
 void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix) const
@@ -53,50 +47,26 @@ void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix
                        planes[i]->update_shader_data(shdata, view_inverse, i);
 }
 
-void Clipping::bind(bool legacy) const
+void Clipping::bind() const
 {
-       if(legacy)
-               static Require _req(MSP_legacy_features);
-       
-       if(legacy!=bound_with_legacy)
-               unbind();
+       static Require _req(MSP_clipping);
 
        const Clipping *old = current();
        if(!set_current(this))
                return;
 
-       bound_with_legacy = legacy;
-       if(legacy)
+       for(unsigned i=0; i<planes.size(); ++i)
        {
-               for(unsigned i=0; i<planes.size(); ++i)
-               {
-                       if(planes[i])
-                               planes[i]->bind_to(i);
-                       else
-                               ClipPlane::unbind_from(i);
-               }
-
-               if(old)
-               {
-                       for(unsigned i=planes.size(); i<old->planes.size(); ++i)
-                               ClipPlane::unbind_from(i);
-               }
+               if(planes[i])
+                       enable(GL_CLIP_PLANE0+i);
+               else
+                       disable(GL_CLIP_PLANE0+i);
        }
-       else
+
+       if(old)
        {
-               for(unsigned i=0; i<planes.size(); ++i)
-               {
-                       if(planes[i])
-                               enable(GL_CLIP_PLANE0+i);
-                       else
-                               disable(GL_CLIP_PLANE0+i);
-               }
-
-               if(old)
-               {
-                       for(unsigned i=planes.size(); i<old->planes.size(); ++i)
-                               disable(GL_CLIP_PLANE0+i);
-               }
+               for(unsigned i=planes.size(); i<old->planes.size(); ++i)
+                       disable(GL_CLIP_PLANE0+i);
        }
 }
 
@@ -106,18 +76,9 @@ void Clipping::unbind()
        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);
-       }
+       for(unsigned i=0; i<old->planes.size(); ++i)
+               if(old->planes[i])
+                       disable(GL_CLIP_PLANE0+i);
 }
 
 } // namespace GL