X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fclipping.cpp;h=6508ecf7f695306df3e76cf4e7f03689e00eee8b;hp=487eeca638cbcfd7a33e1c04e086b124c47b7cbd;hb=HEAD;hpb=2a27f2d40ef2359e347c838887101904789941d2 diff --git a/source/clipping.cpp b/source/clipping.cpp deleted file mode 100644 index 487eeca6..00000000 --- a/source/clipping.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include "clipping.h" -#include "clipplane.h" -#include "clipunit.h" -#include "matrix.h" -#include "misc.h" - -using namespace std; - -namespace Msp { -namespace GL { - -bool Clipping::bound_with_legacy = false; - -void Clipping::attach(unsigned i, const ClipPlane &p) -{ - if(i>=ClipUnit::get_n_units()) - throw out_of_range("Clipping::attach"); - - if(i>=planes.size()) - planes.resize(i+1); - - planes[i] = &p; - if(current()==this) - { - if(bound_with_legacy) - p.bind_to(i); - else - glEnable(GL_CLIP_PLANE0+i); - } -} - -void Clipping::detach(unsigned i) -{ - if(i>=planes.size()) - return; - - planes[i] = 0; - if(current()==this) - { - if(bound_with_legacy) - ClipPlane::unbind_from(i); - else - disable(GL_CLIP_PLANE0+i); - } -} - -void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix) const -{ - Matrix view_inverse = invert(view_matrix); - for(unsigned i=0; iupdate_shader_data(shdata, view_inverse, i); -} - -void Clipping::bind(bool legacy) const -{ - if(legacy) - static Require _req(MSP_legacy_features); - - const Clipping *old = current(); - if(!set_current(this) && !(legacy && !bound_with_legacy)) - return; - - bound_with_legacy = legacy; - if(legacy) - { - for(unsigned i=0; ibind_to(i); - else - ClipPlane::unbind_from(i); - } - - if(old) - { - for(unsigned i=planes.size(); iplanes.size(); ++i) - ClipPlane::unbind_from(i); - } - } - else - { - 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(bound_with_legacy) - { - for(unsigned i=0; iplanes.size(); ++i) - if(old->planes[i]) - ClipPlane::unbind_from(i); - } - else - { - for(unsigned i=0; iplanes.size(); ++i) - if(old->planes[i]) - disable(GL_CLIP_PLANE0+i); - } -} - -} // namespace GL -} // namespace Msp