]> git.tdb.fi Git - libs/gl.git/blob - source/core/pipelinestate.h
Use default member initializers for simple types
[libs/gl.git] / source / core / pipelinestate.h
1 #ifndef MSP_GL_PIPELINESTATE_H_
2 #define MSP_GL_PIPELINESTATE_H_
3
4 #include <vector>
5 #include <msp/core/noncopyable.h>
6 #include "cullface.h"
7 #include "pipelinestate_backend.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Blend;
13 class DepthTest;
14 class Framebuffer;
15 class Program;
16 class Rect;
17 class Sampler;
18 class StencilTest;
19 class Texture;
20 class UniformBlock;
21 class VertexSetup;
22
23 class PipelineState: public PipelineStateBackend
24 {
25         friend PipelineStateBackend;
26
27 private:
28         struct BoundTexture
29         {
30                 unsigned binding;
31                 mutable bool changed;
32                 const Texture *texture;
33                 const Sampler *sampler;
34
35                 BoundTexture(unsigned);
36         };
37
38         struct BoundUniformBlock
39         {
40                 int binding;
41                 mutable bool changed;
42                 const UniformBlock *block;
43
44                 BoundUniformBlock(int);
45         };
46
47         enum ChangeMask
48         {
49                 SHPROG = 1,
50                 VERTEX_SETUP = 2,
51                 FACE_CULL = 4,
52                 CLIP_PLANES = 8,
53                 TEXTURES = 16,
54                 UNIFORMS = 32,
55                 DEPTH_TEST = 64,
56                 STENCIL_TEST = 128,
57                 BLEND = 256,
58                 FRAMEBUFFER = 512,
59                 VIEWPORT = 1024,
60                 SCISSOR = 2048
61         };
62
63         const Framebuffer *framebuffer = 0;
64         const Rect *viewport = 0;
65         const Rect *scissor = 0;
66         const Program *shprog = 0;
67         const VertexSetup *vertex_setup = 0;
68         FaceWinding front_face = COUNTERCLOCKWISE;
69         CullMode face_cull = NO_CULL;
70         unsigned enabled_clip_planes = 0;
71         std::vector<BoundTexture> textures;
72         std::vector<BoundUniformBlock> uniform_blocks;
73         const DepthTest *depth_test = 0;
74         const StencilTest *stencil_test = 0;
75         const Blend *blend = 0;
76         mutable unsigned changes = 0;
77
78         template<typename T>
79         void set(T &, T, unsigned);
80 public:
81         void set_framebuffer(const Framebuffer *);
82         void set_viewport(const Rect *);
83         void set_scissor(const Rect *);
84         void set_shader_program(const Program *);
85         void set_vertex_setup(const VertexSetup *);
86         void set_front_face(FaceWinding);
87         void set_face_cull(CullMode);
88         void set_enabled_clip_planes(unsigned);
89         void set_texture(unsigned, const Texture *, const Sampler *);
90         void set_uniform_block(int, const UniformBlock *);
91         void set_depth_test(const DepthTest *);
92         void set_stencil_test(const StencilTest *);
93         void set_blend(const Blend *);
94
95         const Framebuffer *get_framebuffer() const { return framebuffer; }
96         const Program *get_shader_program() const { return shprog; }
97         const VertexSetup *get_vertex_setup() const { return vertex_setup; }
98         FaceWinding get_front_face() const { return front_face; }
99         CullMode get_face_cull() const { return face_cull; }
100 };
101
102 } // namespace GL
103 } // namespace Msp
104
105 #endif