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_texture(unsigned binding, const Texture *tex, const Sampler *samp)
57 if((tex!=0)!=(samp!=0))
58 throw invalid_argument("PipelineState::set_texture");
60 auto i = lower_bound_member(textures, binding, &BoundTexture::binding);
61 if(i==textures.end() || i->binding!=binding)
62 i = textures.insert(i, BoundTexture(binding));
63 if(tex!=i->texture || samp!=i->sampler)
72 void PipelineState::set_uniform_block(int binding, const UniformBlock *block)
74 auto i = lower_bound_member(uniform_blocks, binding, &BoundUniformBlock::binding);
75 if(i==uniform_blocks.end() || i->binding!=binding)
76 i = uniform_blocks.insert(i, BoundUniformBlock(binding));
77 if(block!=i->block || binding<0)
85 void PipelineState::set_depth_test(const DepthTest *dt)
87 set(depth_test, dt, DEPTH_TEST);
90 void PipelineState::set_stencil_test(const StencilTest *st)
92 set(stencil_test, st, STENCIL_TEST);
95 void PipelineState::set_blend(const Blend *b)
101 PipelineState::BoundTexture::BoundTexture(unsigned b):
109 PipelineState::BoundUniformBlock::BoundUniformBlock(int b):