]> git.tdb.fi Git - libs/gl.git/blobdiff - source/blend.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / blend.cpp
index 899ccf599c255e8141fb14c2e3046af6fceaddbc..03fc0f02baf32c917e1be36ad9ec33f7237f9233 100644 (file)
@@ -1,11 +1,3 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2008  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#define GL_GLEXT_PROTOTYPES
 #include "blend.h"
 #include "extension.h"
 #include "version_1_2.h"
@@ -13,15 +5,48 @@ Distributed under the LGPL
 namespace Msp {
 namespace GL {
 
-void blend_equation(BlendEquation eq)
+Blend::Blend():
+       eq(ADD),
+       src_factor(ONE),
+       dst_factor(ZERO)
+{ }
+
+Blend::Blend(BlendFactor sf, BlendFactor df):
+       eq(ADD),
+       src_factor(sf),
+       dst_factor(df)
+{ }
+
+Blend::Blend(BlendEquation e, BlendFactor sf, BlendFactor df):
+       eq(e),
+       src_factor(sf),
+       dst_factor(df)
+{
+       if(eq!=ADD)
+               static RequireVersion _ver(1, 2);
+}
+
+void Blend::bind() const
+{
+       if(set_current(this))
+       {
+               glEnable(GL_BLEND);
+               if(glBlendEquation)
+                       glBlendEquation(eq);
+               glBlendFunc(src_factor, dst_factor);
+       }
+}
+
+void Blend::unbind()
 {
-       require_version(1, 2);
-       glBlendEquation(eq);
+       if(set_current(0))
+               glDisable(GL_BLEND);
 }
 
-void blend_func(BlendFactor src, BlendFactor dst)
+const Blend &Blend::alpha()
 {
-       glBlendFunc(src, dst);
+       static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
+       return blend;
 }
 
 } // namespace GL