X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fblend.h;h=986844c0e6a7e1f2caa15249a8c7d8531bd4bf09;hp=e7b291e617dab5c2044e787c99ee7a09a7dfcac5;hb=2b2676392aff2eb6b38c3e463cc67f4d67a4ef8b;hpb=669e9bfc18d2f5e28a9c715e1a69b7637a2d9c8b diff --git a/source/core/blend.h b/source/core/blend.h index e7b291e6..986844c0 100644 --- a/source/core/blend.h +++ b/source/core/blend.h @@ -1,64 +1,73 @@ #ifndef MSP_GL_BLEND_H_ #define MSP_GL_BLEND_H_ +#include #include -#include "bindable.h" +#include "color.h" #include "gl.h" -#include namespace Msp { namespace GL { enum BlendEquation { - ADD = GL_FUNC_ADD, - SUBTRACT = GL_FUNC_SUBTRACT, - REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT, - MIN = GL_MIN, - MAX = GL_MAX + ADD, + SUBTRACT, + REVERSE_SUBTRACT, + MIN, + MAX }; enum BlendFactor { - ZERO = GL_ZERO, - ONE = GL_ONE, - SRC_COLOR = GL_SRC_COLOR, - ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, - SRC_ALPHA = GL_SRC_ALPHA, - ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA, - DST_COLOR = GL_DST_COLOR, - ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, - DST_ALPHA = GL_DST_ALPHA, - ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, - CONSTANT_COLOR = GL_CONSTANT_COLOR, - ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR, - CONSTANT_ALPHA = GL_CONSTANT_ALPHA, - ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA + ZERO, + ONE, + SRC_COLOR, + ONE_MINUS_SRC_COLOR, + SRC_ALPHA, + ONE_MINUS_SRC_ALPHA, + DST_COLOR, + ONE_MINUS_DST_COLOR, + DST_ALPHA, + ONE_MINUS_DST_ALPHA, + CONSTANT_COLOR, + ONE_MINUS_CONSTANT_COLOR, + CONSTANT_ALPHA, + ONE_MINUS_CONSTANT_ALPHA }; /** Blends incoming fragments with those already in the framebuffer. */ -class Blend: public Bindable +struct Blend { -private: - BlendEquation eq; + class Loader: public DataFile::ObjectLoader + { + public: + Loader(Blend &); + + private: + void constant(float, float, float, float); + void equation(BlendEquation); + void factors(BlendFactor, BlendFactor); + }; + + bool enabled; + BlendEquation equation; BlendFactor src_factor; BlendFactor dst_factor; + Color constant; -public: Blend(); Blend(BlendFactor, BlendFactor); Blend(BlendEquation, BlendFactor, BlendFactor); +}; - void bind() const; - - static void unbind(); +GLenum get_gl_blend_equation(BlendEquation); +GLenum get_gl_blend_factor(BlendFactor); - static const Blend &alpha(); - static const Blend &additive(); - static const Blend &additive_alpha(); -}; +void operator>>(const LexicalConverter &, BlendEquation &); +void operator<<(LexicalConverter &, BlendEquation); void operator>>(const LexicalConverter &, BlendFactor &); void operator<<(LexicalConverter &, BlendFactor);