]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/clipping.cpp
Use C++11 features with containers
[libs/gl.git] / source / core / clipping.cpp
index 18b706e78b1b34e9205879acd51cf83d10ad9cbb..d23ecffc0c2549c5eb2d3fe837213a63e99b337e 100644 (file)
@@ -1,10 +1,8 @@
 #include <msp/core/algorithm.h>
-#include <msp/gl/extensions/msp_clipping.h>
 #include "clipping.h"
 #include "clipplane.h"
+#include "deviceinfo.h"
 #include "error.h"
-#include "matrix.h"
-#include "misc.h"
 
 using namespace std;
 
@@ -13,33 +11,24 @@ namespace GL {
 
 unsigned Clipping::get_n_attach_points()
 {
-       static Require _req(MSP_clipping);
-       static int count = get_i(GL_MAX_CLIP_PLANES);
-       return count;
+       return Limits::get_global().max_clip_planes;
 }
 
 void Clipping::attach(const ClipPlane &p)
 {
        if(find_member(planes, &p, &AttachedPlane::plane)!=planes.end())
                return;
-       if(planes.size()>=get_n_attach_points())
+       if(planes.size()>=Limits::get_global().max_clip_planes)
                throw invalid_operation("Clipping::attach");
 
        planes.push_back(&p);
-       if(current()==this)
-               glEnable(GL_CLIP_PLANE0+planes.size()-1);
 }
 
 void Clipping::detach(const ClipPlane &p)
 {
-       vector<AttachedPlane>::iterator i = find_member(planes, &p, &AttachedPlane::plane);
+       auto i = find_member(planes, &p, &AttachedPlane::plane);
        if(i!=planes.end())
-       {
                planes.erase(i);
-               if(current()==this)
-                       disable(GL_CLIP_PLANE0+planes.size());
-
-       }
 }
 
 void Clipping::detach(unsigned i)
@@ -60,33 +49,5 @@ const ProgramData &Clipping::get_shader_data() const
        return shdata;
 }
 
-void Clipping::bind() const
-{
-       static Require _req(MSP_clipping);
-
-       const Clipping *old = current();
-       if(!set_current(this))
-               return;
-
-       for(unsigned i=0; i<planes.size(); ++i)
-               enable(GL_CLIP_PLANE0+i);
-
-       if(old)
-       {
-               for(unsigned i=planes.size(); i<old->planes.size(); ++i)
-                       disable(GL_CLIP_PLANE0+i);
-       }
-}
-
-void Clipping::unbind()
-{
-       const Clipping *old = current();
-       if(!set_current(0))
-               return;
-
-       for(unsigned i=0; i<old->planes.size(); ++i)
-               disable(GL_CLIP_PLANE0+i);
-}
-
 } // namespace GL
 } // namespace Msp