1 #ifndef MSP_GL_PIPELINESTATE_H_
2 #define MSP_GL_PIPELINESTATE_H_
5 #include <msp/core/noncopyable.h>
7 #include "pipelinestate_backend.h"
8 #include "primitivetype.h"
25 Stores state for the entire GPU pipeline.
27 Applications normally use the higher-level Renderer class rather than this.
29 class PipelineState: public PipelineStateBackend
31 friend PipelineStateBackend;
37 mutable bool changed = false;
38 mutable bool used = false;
39 const Texture *texture = 0;
40 const Sampler *sampler = 0;
42 BoundTexture(unsigned b): binding(b) { }
45 struct BoundUniformBlock
48 mutable bool changed = false;
49 mutable bool used = false;
50 const UniformBlock *block = 0;
52 BoundUniformBlock(int b): binding(b) { }
71 const Framebuffer *framebuffer = 0;
72 const Rect *viewport = 0;
73 const Rect *scissor = 0;
74 const Program *shprog = 0;
75 std::vector<BoundUniformBlock> uniform_blocks;
76 std::vector<BoundTexture> textures;
77 const VertexSetup *vertex_setup = 0;
78 PrimitiveType primitive_type = TRIANGLES;
79 FaceWinding front_face = COUNTERCLOCKWISE;
80 CullMode face_cull = NO_CULL;
81 const DepthTest *depth_test = 0;
82 const StencilTest *stencil_test = 0;
83 const Blend *blend = 0;
86 void set(T &, T, unsigned);
88 void set_framebuffer(const Framebuffer *);
89 void set_viewport(const Rect *);
90 void set_scissor(const Rect *);
91 void set_shader_program(const Program *);
92 void set_uniform_block(int, const UniformBlock *);
93 void set_texture(unsigned, const Texture *, const Sampler *);
94 void set_vertex_setup(const VertexSetup *);
95 void set_primitive_type(PrimitiveType);
96 void set_front_face(FaceWinding);
97 void set_face_cull(CullMode);
98 void set_depth_test(const DepthTest *);
99 void set_stencil_test(const StencilTest *);
100 void set_blend(const Blend *);
102 const Framebuffer *get_framebuffer() const { return framebuffer; }
103 const Rect *get_viewport() const { return viewport; }
104 const Program *get_shader_program() const { return shprog; }
105 const VertexSetup *get_vertex_setup() const { return vertex_setup; }
106 FaceWinding get_front_face() const { return front_face; }
107 CullMode get_face_cull() const { return face_cull; }