]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pipelinestate.cpp
Add color write mask to blend state
[libs/gl.git] / source / core / pipelinestate.cpp
index 871336bb76b25b43b6928aa41b7384e7f0410f5b..262dd26b596b95fb600aea40d5995d0fe08fd56e 100644 (file)
@@ -5,6 +5,7 @@
 #include <msp/gl/extensions/arb_shader_objects.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_array_object.h>
+#include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/msp_primitive_restart.h>
 #include "blend.h"
 #include "buffer.h"
@@ -45,9 +46,9 @@ PipelineState::PipelineState():
        changes(0)
 {
        if(bound_tex_targets.empty())
-               bound_tex_targets.resize(Limits::get_global().max_texture_bindings);
+               bound_tex_targets.resize(DeviceInfo::get_global().limits.max_texture_bindings);
        if(bound_uniform_blocks.empty())
-               bound_uniform_blocks.resize(Limits::get_global().max_uniform_bindings);
+               bound_uniform_blocks.resize(DeviceInfo::get_global().limits.max_uniform_bindings);
 }
 
 PipelineState::~PipelineState()
@@ -227,7 +228,7 @@ void PipelineState::apply(unsigned mask) const
 
        if(mask&CLIP_PLANES)
        {
-               unsigned max_clip_planes = Limits::get_global().max_clip_planes;
+               unsigned max_clip_planes = DeviceInfo::get_global().limits.max_clip_planes;
                for(unsigned i=0; i<max_clip_planes; ++i)
                {
                        if((enabled_clip_planes>>i)&1)
@@ -321,9 +322,14 @@ void PipelineState::apply(unsigned mask) const
                        glBlendEquation(get_gl_blend_equation(blend->equation));
                        glBlendFunc(get_gl_blend_factor(blend->src_factor), get_gl_blend_factor(blend->dst_factor));
                        glBlendColor(blend->constant.r, blend->constant.g, blend->constant.b, blend->constant.a);
+                       ColorWriteMask cw = blend->write_mask;
+                       glColorMask((cw&WRITE_RED)!=0, (cw&WRITE_GREEN)!=0, (cw&WRITE_BLUE)!=0, (cw&WRITE_ALPHA)!=0);
                }
                else
+               {
                        glDisable(GL_BLEND);
+                       glColorMask(true, true, true, true);
+               }
        }
 
        last_applied = this;
@@ -337,7 +343,7 @@ void PipelineState::clear()
                glUseProgram(0);
                glBindVertexArray(0);
 
-               unsigned max_clip_planes = Limits::get_global().max_clip_planes;
+               unsigned max_clip_planes = DeviceInfo::get_global().limits.max_clip_planes;
                for(unsigned i=0; i<max_clip_planes; ++i)
                        if((last_applied->enabled_clip_planes>>i)&1)
                                glDisable(GL_CLIP_PLANE0+i);