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_uniform_block(int binding, const UniformBlock *block)
42 auto i = lower_bound_member(uniform_blocks, binding, &BoundUniformBlock::binding);
43 if(i==uniform_blocks.end() || i->binding!=binding)
44 i = uniform_blocks.insert(i, BoundUniformBlock(binding));
45 if(block!=i->block || binding<0)
53 void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp)
55 if((tex!=0)!=(samp!=0))
56 throw invalid_argument("PipelineState::set_texture");
58 auto i = lower_bound_member(textures, binding, &BoundTexture::binding);
59 if(i==textures.end() || i->binding!=binding)
60 i = textures.insert(i, BoundTexture(binding));
61 if(tex!=i->texture || samp!=i->sampler)
70 void PipelineState::set_vertex_setup(const VertexSetup *s)
72 set(vertex_setup, s, VERTEX_SETUP);
75 void PipelineState::set_primitive_type(PrimitiveType t)
77 set(primitive_type, t, PRIMITIVE_TYPE);
80 void PipelineState::set_front_face(FaceWinding w)
82 set(front_face, w, FACE_CULL);
85 void PipelineState::set_face_cull(CullMode c)
87 set(face_cull, c, FACE_CULL);
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);