X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fblend.cpp;h=df4043e29fcfc228a557a7a5f54238d1f302f5e2;hb=0807680edd94a7f14560831db4dd52e4e48d0d19;hp=8b82772fded1e7fc6acc755c312964ac867a0b3b;hpb=f17794d55923d4fb4f63e9d082d8d84a735a04e8;p=libs%2Fgl.git diff --git a/source/blend.cpp b/source/blend.cpp index 8b82772f..df4043e2 100644 --- a/source/blend.cpp +++ b/source/blend.cpp @@ -1,13 +1,6 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include +#include #include "blend.h" -#include "extension.h" -#include "version_1_2.h" namespace Msp { namespace GL { @@ -29,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 @@ -38,34 +33,34 @@ void Blend::bind() const if(set_current(this)) { glEnable(GL_BLEND); - // XXX Don't try to set equation if version < 1.2 - glBlendEquation(eq); + if(EXT_blend_minmax) + glBlendEquation(eq); glBlendFunc(src_factor, dst_factor); } } -const Blend &Blend::alpha() -{ - static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); - return blend; -} - 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; +} -void blend_equation(BlendEquation eq) +const Blend &Blend::additive() { - static RequireVersion _ver(1, 2); - glBlendEquation(eq); + static Blend blend(ONE, ONE); + return blend; } -void blend_func(BlendFactor src, BlendFactor dst) +const Blend &Blend::additive_alpha() { - glBlendFunc(src, dst); + static Blend blend(SRC_ALPHA, ONE); + return blend; } } // namespace GL