]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/blend_backend.cpp
Move all OpenGL-specific code to a separate directory
[libs/gl.git] / source / backends / opengl / blend_backend.cpp
diff --git a/source/backends/opengl/blend_backend.cpp b/source/backends/opengl/blend_backend.cpp
new file mode 100644 (file)
index 0000000..4426748
--- /dev/null
@@ -0,0 +1,49 @@
+#include <stdexcept>
+#include <msp/gl/extensions/ext_blend_minmax.h>
+#include <msp/gl/extensions/ext_blend_subtract.h>
+#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