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;
43 BoundTexture(unsigned b): binding(b) { }
46 struct BoundUniformBlock
49 mutable bool changed = false;
50 mutable bool used = false;
51 const UniformBlock *block = 0;
53 BoundUniformBlock(int b): binding(b) { }
72 const Framebuffer *framebuffer = 0;
73 const Rect *viewport = 0;
74 const Rect *scissor = 0;
75 const Program *shprog = 0;
76 std::vector<BoundUniformBlock> uniform_blocks;
77 std::vector<BoundTexture> textures;
78 const VertexSetup *vertex_setup = 0;
79 PrimitiveType primitive_type = TRIANGLES;
80 FaceWinding front_face = COUNTERCLOCKWISE;
81 CullMode face_cull = NO_CULL;
82 const DepthTest *depth_test = 0;
83 const StencilTest *stencil_test = 0;
84 const Blend *blend = 0;
87 void set(T &, T, unsigned);
89 void set_framebuffer(const Framebuffer *);
90 void set_viewport(const Rect *);
91 void set_scissor(const Rect *);
92 void set_shader_program(const Program *);
93 void set_uniform_block(int, const UniformBlock *);
94 void set_texture(unsigned, const Texture *, const Sampler *);
95 void set_texture(unsigned, const Texture *, int, const Sampler *);
96 void set_vertex_setup(const VertexSetup *);
97 void set_primitive_type(PrimitiveType);
98 void set_front_face(FaceWinding);
99 void set_face_cull(CullMode);
100 void set_depth_test(const DepthTest *);
101 void set_stencil_test(const StencilTest *);
102 void set_blend(const Blend *);
104 const Framebuffer *get_framebuffer() const { return framebuffer; }
105 const Rect *get_viewport() const { return viewport; }
106 const Program *get_shader_program() const { return shprog; }
107 const VertexSetup *get_vertex_setup() const { return vertex_setup; }
108 FaceWinding get_front_face() const { return front_face; }
109 CullMode get_face_cull() const { return face_cull; }