]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pipelinestate.h
Use default member initializers for simple types
[libs/gl.git] / source / core / pipelinestate.h
index 9f6795f16ec176d0cb4204354dcd7b4b7a4ad53e..0d0520a0262565a1c56a9b78ab9bece536677e95 100644 (file)
@@ -1,16 +1,15 @@
-#ifndef PIPELINESTATE_H_
-#define PIPELINESTATE_H_
+#ifndef MSP_GL_PIPELINESTATE_H_
+#define MSP_GL_PIPELINESTATE_H_
 
 #include <vector>
 #include <msp/core/noncopyable.h>
 #include "cullface.h"
+#include "pipelinestate_backend.h"
 
 namespace Msp {
 namespace GL {
 
 class Blend;
-class BufferBackedUniformBlock;
-class DefaultUniformBlock;
 class DepthTest;
 class Framebuffer;
 class Program;
@@ -20,10 +19,11 @@ class StencilTest;
 class Texture;
 class UniformBlock;
 class VertexSetup;
-class WindingTest;
 
-class PipelineState: public NonCopyable
+class PipelineState: public PipelineStateBackend
 {
+       friend PipelineStateBackend;
+
 private:
        struct BoundTexture
        {
@@ -60,29 +60,21 @@ private:
                SCISSOR = 2048
        };
 
-       const Framebuffer *framebuffer;
-       const Rect *viewport;
-       const Rect *scissor;
-       const Program *shprog;
-       const VertexSetup *vertex_setup;
-       FaceWinding front_face;
-       CullMode face_cull;
-       unsigned enabled_clip_planes;
+       const Framebuffer *framebuffer = 0;
+       const Rect *viewport = 0;
+       const Rect *scissor = 0;
+       const Program *shprog = 0;
+       const VertexSetup *vertex_setup = 0;
+       FaceWinding front_face = COUNTERCLOCKWISE;
+       CullMode face_cull = NO_CULL;
+       unsigned enabled_clip_planes = 0;
        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;
-       static std::vector<int> bound_tex_targets;
+       const DepthTest *depth_test = 0;
+       const StencilTest *stencil_test = 0;
+       const Blend *blend = 0;
+       mutable unsigned changes = 0;
 
-public:
-       PipelineState();
-       ~PipelineState();
-
-private:
        template<typename T>
        void set(T &, T, unsigned);
 public:
@@ -95,25 +87,16 @@ public:
        void set_face_cull(CullMode);
        void set_enabled_clip_planes(unsigned);
        void set_texture(unsigned, const Texture *, const Sampler *);
-       void set_uniforms(const DefaultUniformBlock *);
-       void set_uniform_block(unsigned, const BufferBackedUniformBlock *);
-private:
-       void set_uniform_block_(int, const UniformBlock *);
-public:
+       void set_uniform_block(int, const UniformBlock *);
        void set_depth_test(const DepthTest *);
        void set_stencil_test(const StencilTest *);
        void set_blend(const Blend *);
 
+       const Framebuffer *get_framebuffer() const { return framebuffer; }
        const Program *get_shader_program() const { return shprog; }
        const VertexSetup *get_vertex_setup() const { return vertex_setup; }
        FaceWinding get_front_face() const { return front_face; }
        CullMode get_face_cull() const { return face_cull; }
-
-       void apply() const;
-private:
-       void apply(unsigned) const;
-public:
-       static void clear();
 };
 
 } // namespace GL