]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/blend_backend.cpp
Add support for padding in vertex formats
[libs/gl.git] / source / backends / opengl / blend_backend.cpp
1 #include <stdexcept>
2 #include <msp/gl/extensions/ext_blend_minmax.h>
3 #include <msp/gl/extensions/ext_blend_subtract.h>
4 #include "blend.h"
5 #include "blend_backend.h"
6 #include "gl.h"
7
8 using namespace std;
9
10 namespace Msp {
11 namespace GL {
12
13 unsigned get_gl_blend_equation(BlendEquation eq)
14 {
15         switch(eq)
16         {
17         case ADD: return GL_FUNC_ADD;
18         case SUBTRACT: return GL_FUNC_SUBTRACT;
19         case REVERSE_SUBTRACT: return GL_FUNC_REVERSE_SUBTRACT;
20         case MIN: return GL_MIN;
21         case MAX: return GL_MAX;
22         default: throw invalid_argument("get_gl_blend_equation");
23         }
24 }
25
26 unsigned get_gl_blend_factor(BlendFactor factor)
27 {
28         switch(factor)
29         {
30         case ZERO: return GL_ZERO;
31         case ONE: return GL_ONE;
32         case SRC_COLOR: return GL_SRC_COLOR;
33         case ONE_MINUS_SRC_COLOR: return GL_ONE_MINUS_SRC_COLOR;
34         case SRC_ALPHA: return GL_SRC_ALPHA;
35         case ONE_MINUS_SRC_ALPHA: return GL_ONE_MINUS_SRC_ALPHA;
36         case DST_COLOR: return GL_DST_COLOR;
37         case ONE_MINUS_DST_COLOR: return GL_ONE_MINUS_DST_COLOR;
38         case DST_ALPHA: return GL_DST_ALPHA;
39         case ONE_MINUS_DST_ALPHA: return GL_ONE_MINUS_DST_ALPHA;
40         case CONSTANT_COLOR: return GL_CONSTANT_COLOR;
41         case ONE_MINUS_CONSTANT_COLOR: return GL_ONE_MINUS_CONSTANT_COLOR;
42         case CONSTANT_ALPHA: return GL_CONSTANT_ALPHA;
43         case ONE_MINUS_CONSTANT_ALPHA: return GL_ONE_MINUS_CONSTANT_ALPHA;
44         default: throw invalid_argument("get_gl_blend_factor");
45         }
46 }
47
48 } // namespace GL
49 } // namespace Msp