blob: 87b3a96284a1309f61ad36e9e17b3b68f60a0d2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#include <mbgl/gl/enum.hpp>
#include <mbgl/gfx/types.hpp>
#include <mbgl/gl/defines.hpp>
namespace mbgl {
namespace gl {
// template <>
// gfx::PrimitiveType Enum::from(const platform::GLint value) {
// }
// template <>
// platform::GLenum Enum::to(const gfx::PrimitiveType value) {
// }
template <>
platform::GLenum Enum<gfx::PrimitiveType>::to(const gfx::PrimitiveType value) {
switch (value) {
case gfx::PrimitiveType::Points: return GL_POINTS;
case gfx::PrimitiveType::Lines: return GL_LINES;
case gfx::PrimitiveType::LineLoop: return GL_LINE_LOOP;
case gfx::PrimitiveType::LineStrip: return GL_LINE_STRIP;
case gfx::PrimitiveType::Triangles: return GL_TRIANGLES;
case gfx::PrimitiveType::TriangleStrip: return GL_TRIANGLE_STRIP;
case gfx::PrimitiveType::TriangleFan: return GL_TRIANGLE_FAN;
}
return GL_INVALID_ENUM;
}
template <>
gfx::ColorBlendEquationType Enum<gfx::ColorBlendEquationType>::from(const platform::GLint value) {
switch (value) {
case GL_FUNC_ADD: return gfx::ColorBlendEquationType::Add;
case GL_FUNC_SUBTRACT: return gfx::ColorBlendEquationType::Subtract;
case GL_FUNC_REVERSE_SUBTRACT: return gfx::ColorBlendEquationType::ReverseSubtract;
}
return {};
}
template <>
platform::GLenum Enum<gfx::ColorBlendEquationType>::to(const gfx::ColorBlendEquationType value) {
switch (value) {
case gfx::ColorBlendEquationType::Add: return GL_FUNC_ADD;
case gfx::ColorBlendEquationType::Subtract: return GL_FUNC_SUBTRACT;
case gfx::ColorBlendEquationType::ReverseSubtract: return GL_FUNC_REVERSE_SUBTRACT;
}
return GL_INVALID_ENUM;
}
template <>
gfx::ColorBlendFactorType Enum<gfx::ColorBlendFactorType>::from(const platform::GLint blendFactor) {
switch (blendFactor) {
case GL_ZERO: return gfx::ColorBlendFactorType::Zero;
case GL_ONE: return gfx::ColorBlendFactorType::One;
case GL_SRC_COLOR: return gfx::ColorBlendFactorType::SrcColor;
case GL_ONE_MINUS_SRC_COLOR: return gfx::ColorBlendFactorType::OneMinusSrcColor;
case GL_DST_COLOR: return gfx::ColorBlendFactorType::DstColor;
case GL_ONE_MINUS_DST_COLOR: return gfx::ColorBlendFactorType::OneMinusDstColor;
case GL_SRC_ALPHA: return gfx::ColorBlendFactorType::SrcAlpha;
case GL_ONE_MINUS_SRC_ALPHA: return gfx::ColorBlendFactorType::OneMinusSrcAlpha;
case GL_DST_ALPHA: return gfx::ColorBlendFactorType::DstAlpha;
case GL_ONE_MINUS_DST_ALPHA: return gfx::ColorBlendFactorType::OneMinusDstAlpha;
case GL_CONSTANT_COLOR: return gfx::ColorBlendFactorType::ConstantColor;
case GL_ONE_MINUS_CONSTANT_COLOR: return gfx::ColorBlendFactorType::OneMinusConstantColor;
case GL_CONSTANT_ALPHA: return gfx::ColorBlendFactorType::ConstantAlpha;
case GL_ONE_MINUS_CONSTANT_ALPHA: return gfx::ColorBlendFactorType::OneMinusConstantAlpha;
case GL_SRC_ALPHA_SATURATE: return gfx::ColorBlendFactorType::SrcAlphaSaturate;
}
return {};
}
template <>
platform::GLenum Enum<gfx::ColorBlendFactorType>::to(const gfx::ColorBlendFactorType value) {
switch (value) {
case gfx::ColorBlendFactorType::Zero: return GL_ZERO;
case gfx::ColorBlendFactorType::One: return GL_ONE;
case gfx::ColorBlendFactorType::SrcColor: return GL_SRC_COLOR;
case gfx::ColorBlendFactorType::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
case gfx::ColorBlendFactorType::DstColor: return GL_DST_COLOR;
case gfx::ColorBlendFactorType::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
case gfx::ColorBlendFactorType::SrcAlpha: return GL_SRC_ALPHA;
case gfx::ColorBlendFactorType::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
case gfx::ColorBlendFactorType::DstAlpha: return GL_DST_ALPHA;
case gfx::ColorBlendFactorType::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
case gfx::ColorBlendFactorType::ConstantColor: return GL_CONSTANT_COLOR;
case gfx::ColorBlendFactorType::OneMinusConstantColor: return GL_ONE_MINUS_CONSTANT_COLOR;
case gfx::ColorBlendFactorType::ConstantAlpha: return GL_CONSTANT_ALPHA;
case gfx::ColorBlendFactorType::OneMinusConstantAlpha: return GL_ONE_MINUS_CONSTANT_ALPHA;
case gfx::ColorBlendFactorType::SrcAlphaSaturate: return GL_SRC_ALPHA_SATURATE;
}
return GL_INVALID_ENUM;
}
} // namespace gl
} // namespace mbgl
|