]> git.tdb.fi Git - libs/gl.git/blobdiff - source/blend.cpp
Derive ProgramCompiler::DeclarationCombiner from BlockModifier
[libs/gl.git] / source / blend.cpp
index 03fc0f02baf32c917e1be36ad9ec33f7237f9233..df4043e29fcfc228a557a7a5f54238d1f302f5e2 100644 (file)
@@ -1,6 +1,6 @@
+#include <msp/gl/extensions/ext_blend_minmax.h>
+#include <msp/gl/extensions/ext_blend_subtract.h>
 #include "blend.h"
-#include "extension.h"
-#include "version_1_2.h"
 
 namespace Msp {
 namespace GL {
@@ -22,8 +22,10 @@ Blend::Blend(BlendEquation e, BlendFactor sf, BlendFactor df):
        src_factor(sf),
        dst_factor(df)
 {
-       if(eq!=ADD)
-               static RequireVersion _ver(1, 2);
+       if(eq==MIN || eq==MAX)
+               static Require _req(EXT_blend_minmax);
+       else if(eq==SUBTRACT || eq==REVERSE_SUBTRACT)
+               static Require _req(EXT_blend_subtract);
 }
 
 void Blend::bind() const
@@ -31,7 +33,7 @@ void Blend::bind() const
        if(set_current(this))
        {
                glEnable(GL_BLEND);
-               if(glBlendEquation)
+               if(EXT_blend_minmax)
                        glBlendEquation(eq);
                glBlendFunc(src_factor, dst_factor);
        }
@@ -49,5 +51,17 @@ const Blend &Blend::alpha()
        return blend;
 }
 
+const Blend &Blend::additive()
+{
+       static Blend blend(ONE, ONE);
+       return blend;
+}
+
+const Blend &Blend::additive_alpha()
+{
+       static Blend blend(SRC_ALPHA, ONE);
+       return blend;
+}
+
 } // namespace GL
 } // namespace Msp