2 #include <msp/core/algorithm.h>
3 #include "pipelinestate.h"
11 void PipelineState::set(T &target, T value, unsigned flag)
20 void PipelineState::set_framebuffer(const Framebuffer *f)
22 set(framebuffer, f, FRAMEBUFFER);
25 void PipelineState::set_viewport(const Rect *v)
27 set(viewport, v, VIEWPORT);
30 void PipelineState::set_scissor(const Rect *s)
32 set(scissor, s, SCISSOR);
35 void PipelineState::set_shader_program(const Program *p)
37 set(shprog, p, SHPROG);
40 void PipelineState::set_vertex_setup(const VertexSetup *s)
42 set(vertex_setup, s, VERTEX_SETUP);
45 void PipelineState::set_front_face(FaceWinding w)
47 set(front_face, w, FACE_CULL);
50 void PipelineState::set_face_cull(CullMode c)
52 set(face_cull, c, FACE_CULL);
55 void PipelineState::set_enabled_clip_planes(unsigned p)
57 set(enabled_clip_planes, p, CLIP_PLANES);
60 void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp)
62 if((tex!=0)!=(samp!=0))
63 throw invalid_argument("PipelineState::set_texture");
65 auto i = lower_bound_member(textures, binding, &BoundTexture::binding);
66 if(i==textures.end() || i->binding!=binding)
67 i = textures.insert(i, BoundTexture(binding));
68 if(tex!=i->texture || samp!=i->sampler)
77 void PipelineState::set_uniform_block(int binding, const UniformBlock *block)
79 auto i = lower_bound_member(uniform_blocks, binding, &BoundUniformBlock::binding);
80 if(i==uniform_blocks.end() || i->binding!=binding)
81 i = uniform_blocks.insert(i, BoundUniformBlock(binding));
82 if(block!=i->block || binding<0)
90 void PipelineState::set_depth_test(const DepthTest *dt)
92 set(depth_test, dt, DEPTH_TEST);
95 void PipelineState::set_stencil_test(const StencilTest *st)
97 set(stencil_test, st, STENCIL_TEST);
100 void PipelineState::set_blend(const Blend *b)
102 set(blend, b, BLEND);
106 PipelineState::BoundTexture::BoundTexture(unsigned b):
114 PipelineState::BoundUniformBlock::BoundUniformBlock(int b):