X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fblend.h;fp=source%2Fcore%2Fblend.h;h=e7b291e617dab5c2044e787c99ee7a09a7dfcac5;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/core/blend.h b/source/core/blend.h new file mode 100644 index 00000000..e7b291e6 --- /dev/null +++ b/source/core/blend.h @@ -0,0 +1,69 @@ +#ifndef MSP_GL_BLEND_H_ +#define MSP_GL_BLEND_H_ + +#include +#include "bindable.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 +}; + +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 +}; + +/** +Blends incoming fragments with those already in the framebuffer. +*/ +class Blend: public Bindable +{ +private: + BlendEquation eq; + BlendFactor src_factor; + BlendFactor dst_factor; + +public: + Blend(); + Blend(BlendFactor, BlendFactor); + Blend(BlendEquation, BlendFactor, BlendFactor); + + void bind() const; + + static void unbind(); + + static const Blend &alpha(); + static const Blend &additive(); + static const Blend &additive_alpha(); +}; + +void operator>>(const LexicalConverter &, BlendFactor &); +void operator<<(LexicalConverter &, BlendFactor); + +} // namespace GL +} // namespace Msp + +#endif