]> git.tdb.fi Git - libs/gl.git/blob - source/core/clipping.cpp
Add missing Require to Commands::resolve_multisample
[libs/gl.git] / source / core / clipping.cpp
1 #include <msp/core/algorithm.h>
2 #include "clipping.h"
3 #include "clipplane.h"
4 #include "deviceinfo.h"
5 #include "error.h"
6
7 using namespace std;
8
9 namespace Msp {
10 namespace GL {
11
12 void Clipping::attach(const ClipPlane &p)
13 {
14         if(find_member(planes, &p, &AttachedPlane::plane)!=planes.end())
15                 return;
16         if(planes.size()>=Limits::get_global().max_clip_planes)
17                 throw invalid_operation("Clipping::attach");
18
19         planes.push_back(&p);
20 }
21
22 void Clipping::detach(const ClipPlane &p)
23 {
24         auto i = find_member(planes, &p, &AttachedPlane::plane);
25         if(i!=planes.end())
26                 planes.erase(i);
27 }
28
29 const ProgramData &Clipping::get_shader_data() const
30 {
31         for(unsigned i=0; i<planes.size(); ++i)
32                 if(planes[i].plane->get_generation()!=planes[i].generation)
33                 {
34                         planes[i].plane->update_shader_data(shdata, i);
35                         planes[i].generation = planes[i].plane->get_generation();
36                 }
37
38         return shdata;
39 }
40
41 } // namespace GL
42 } // namespace Msp