X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fclipping.cpp;h=79e1aaf06a149912e0bef36e3ab54583bbcf0993;hb=b466adff89db080c304ac3178ce1f4fef844cb28;hp=c286b7e57677e7880a56908e3dda0f3ff90a15be;hpb=a77629d781eeb789870470c5ebdbd4b691e1b138;p=libs%2Fgl.git diff --git a/source/core/clipping.cpp b/source/core/clipping.cpp index c286b7e5..79e1aaf0 100644 --- a/source/core/clipping.cpp +++ b/source/core/clipping.cpp @@ -1,10 +1,8 @@ #include -#include #include "clipping.h" #include "clipplane.h" +#include "deviceinfo.h" #include "error.h" -#include "matrix.h" -#include "misc.h" using namespace std; @@ -13,74 +11,42 @@ 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(planes, &p)!=planes.end()) + 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::iterator i = find(planes, &p); + vector::iterator 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) { if(iupdate_shader_data(shdata, view_inverse, i); -} - -void Clipping::bind() const -{ - static Require _req(MSP_clipping); - - const Clipping *old = current(); - if(!set_current(this)) - return; - - for(unsigned i=0; iplanes.size(); ++i) - disable(GL_CLIP_PLANE0+i); - } -} - -void Clipping::unbind() -{ - const Clipping *old = current(); - if(!set_current(0)) - return; + if(planes[i].plane->get_generation()!=planes[i].generation) + { + planes[i].plane->update_shader_data(shdata, i); + planes[i].generation = planes[i].plane->get_generation(); + } - for(unsigned i=0; iplanes.size(); ++i) - disable(GL_CLIP_PLANE0+i); + return shdata; } } // namespace GL