-#include <msp/gl/extensions/ext_blend_minmax.h>
-#include <msp/gl/extensions/ext_blend_subtract.h>
-#include "blend.h"
-
-namespace Msp {
-namespace GL {
-
-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==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
-{
- if(set_current(this))
- {
- glEnable(GL_BLEND);
- if(glBlendEquation)
- glBlendEquation(eq);
- glBlendFunc(src_factor, dst_factor);
- }
-}
-
-void Blend::unbind()
-{
- if(set_current(0))
- glDisable(GL_BLEND);
-}
-
-const Blend &Blend::alpha()
-{
- static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
- return blend;
-}
-
-} // namespace GL
-} // namespace Msp