X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Fblend_backend.cpp;fp=source%2Fbackends%2Fopengl%2Fblend_backend.cpp;h=44267480bd180ba16fc32fbea6c34add1977fce9;hb=160e9eea29bd10034733d59507fa1bcca36be401;hp=0000000000000000000000000000000000000000;hpb=93448d16e72e38afbaecbccf6fdedd46d6a82a73;p=libs%2Fgl.git diff --git a/source/backends/opengl/blend_backend.cpp b/source/backends/opengl/blend_backend.cpp new file mode 100644 index 00000000..44267480 --- /dev/null +++ b/source/backends/opengl/blend_backend.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include "blend.h" +#include "blend_backend.h" +#include "gl.h" + +using namespace std; + +namespace Msp { +namespace GL { + +unsigned get_gl_blend_equation(BlendEquation eq) +{ + switch(eq) + { + case ADD: return GL_FUNC_ADD; + case SUBTRACT: return GL_FUNC_SUBTRACT; + case REVERSE_SUBTRACT: return GL_FUNC_REVERSE_SUBTRACT; + case MIN: return GL_MIN; + case MAX: return GL_MAX; + default: throw invalid_argument("get_gl_blend_equation"); + } +} + +unsigned get_gl_blend_factor(BlendFactor factor) +{ + switch(factor) + { + case ZERO: return GL_ZERO; + case ONE: return GL_ONE; + case SRC_COLOR: return GL_SRC_COLOR; + case ONE_MINUS_SRC_COLOR: return GL_ONE_MINUS_SRC_COLOR; + case SRC_ALPHA: return GL_SRC_ALPHA; + case ONE_MINUS_SRC_ALPHA: return GL_ONE_MINUS_SRC_ALPHA; + case DST_COLOR: return GL_DST_COLOR; + case ONE_MINUS_DST_COLOR: return GL_ONE_MINUS_DST_COLOR; + case DST_ALPHA: return GL_DST_ALPHA; + case ONE_MINUS_DST_ALPHA: return GL_ONE_MINUS_DST_ALPHA; + case CONSTANT_COLOR: return GL_CONSTANT_COLOR; + case ONE_MINUS_CONSTANT_COLOR: return GL_ONE_MINUS_CONSTANT_COLOR; + case CONSTANT_ALPHA: return GL_CONSTANT_ALPHA; + case ONE_MINUS_CONSTANT_ALPHA: return GL_ONE_MINUS_CONSTANT_ALPHA; + default: throw invalid_argument("get_gl_blend_factor"); + } +} + +} // namespace GL +} // namespace Msp