]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pipelinestate.h
Redesign depth and stencil test and blend state management
[libs/gl.git] / source / core / pipelinestate.h
index 8d1d1aaa974c85f89637bf3bd5df8ccfc9511615..a931e25c406808232cd07809c44d616d15c5a7d4 100644 (file)
@@ -3,14 +3,18 @@
 
 #include <vector>
 #include <msp/core/noncopyable.h>
+#include "cullface.h"
 
 namespace Msp {
 namespace GL {
 
+class Blend;
 class BufferBackedUniformBlock;
 class DefaultUniformBlock;
+class DepthTest;
 class Program;
 class Sampler;
+class StencilTest;
 class Texture;
 class UniformBlock;
 class VertexSetup;
@@ -42,18 +46,25 @@ private:
        {
                SHPROG = 1,
                VERTEX_SETUP = 2,
-               WINDING_TEST = 4,
+               FACE_CULL = 4,
                CLIP_PLANES = 8,
                TEXTURES = 16,
-               UNIFORMS = 32
+               UNIFORMS = 32,
+               DEPTH_TEST = 64,
+               STENCIL_TEST = 128,
+               BLEND = 256
        };
 
        const Program *shprog;
        const VertexSetup *vertex_setup;
-       const WindingTest *winding_test;
+       FaceWinding front_face;
+       CullMode face_cull;
        unsigned enabled_clip_planes;
        std::vector<BoundTexture> textures;
        std::vector<BoundUniformBlock> uniform_blocks;
+       const DepthTest *depth_test;
+       const StencilTest *stencil_test;
+       const Blend *blend;
        mutable unsigned changes;
 
        static const PipelineState *last_applied;
@@ -63,9 +74,14 @@ public:
        PipelineState();
        ~PipelineState();
 
+private:
+       template<typename T>
+       void set(T &, T, unsigned);
+public:
        void set_shader_program(const Program *);
        void set_vertex_setup(const VertexSetup *);
-       void set_winding_test(const WindingTest *);
+       void set_front_face(FaceWinding);
+       void set_face_cull(CullMode);
        void set_enabled_clip_planes(unsigned);
        void set_texture(unsigned, const Texture *, const Sampler *);
        void set_uniforms(const DefaultUniformBlock *);
@@ -73,10 +89,14 @@ public:
 private:
        void set_uniform_block_(int, const UniformBlock *);
 public:
+       void set_depth_test(const DepthTest *);
+       void set_stencil_test(const StencilTest *);
+       void set_blend(const Blend *);
 
        const Program *get_shader_program() const { return shprog; }
        const VertexSetup *get_vertex_setup() const { return vertex_setup; }
-       const WindingTest *get_winding_test() const { return winding_test; }
+       FaceWinding get_front_face() const { return front_face; }
+       CullMode get_face_cull() const { return face_cull; }
 
        void apply() const;
 private: