summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-08 16:14:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-09-26 11:14:40 +0200
commitadcb449ff348a3ae5f74c38824ae43718122dafa (patch)
tree4d5c204ff3f6e26ca0ae33cd5cbf2b10b88d97b5
parentbf18c330406a44b36218aab20a11b74f0151f6e7 (diff)
downloadqtlocation-mapboxgl-adcb449ff348a3ae5f74c38824ae43718122dafa.tar.gz
[core] make GL value defaults constexpr
-rw-r--r--cmake/core-files.cmake2
-rw-r--r--include/mbgl/gl/gl_values.hpp42
-rw-r--r--src/mbgl/gl/gl_config.cpp32
-rw-r--r--src/mbgl/gl/gl_values.cpp32
4 files changed, 54 insertions, 54 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index fa681a03c4..a69cd1b160 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -82,8 +82,8 @@ set(MBGL_CORE_FILES
src/mbgl/gl/debugging.cpp
src/mbgl/gl/debugging.hpp
src/mbgl/gl/gl.cpp
- src/mbgl/gl/gl_config.cpp
src/mbgl/gl/gl_config.hpp
+ src/mbgl/gl/gl_values.cpp
src/mbgl/gl/object_store.cpp
src/mbgl/gl/object_store.hpp
diff --git a/include/mbgl/gl/gl_values.hpp b/include/mbgl/gl/gl_values.hpp
index 29a5281cca..d251e7bf52 100644
--- a/include/mbgl/gl/gl_values.hpp
+++ b/include/mbgl/gl/gl_values.hpp
@@ -13,7 +13,7 @@ namespace gl {
struct ClearDepth {
using Type = GLfloat;
- static const Type Default;
+ static const constexpr Type Default = 1;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearDepth(value));
}
@@ -26,7 +26,7 @@ struct ClearDepth {
struct ClearColor {
using Type = Color;
- static const Type Default;
+ static const constexpr Type Default = { 0, 0, 0, 0 };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearColor(value.r, value.g, value.b, value.a));
}
@@ -39,7 +39,7 @@ struct ClearColor {
struct ClearStencil {
using Type = GLint;
- static const Type Default;
+ static const constexpr Type Default = 0;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearStencil(value));
}
@@ -52,7 +52,7 @@ struct ClearStencil {
struct StencilMask {
using Type = GLuint;
- static const Type Default;
+ static const constexpr Type Default = ~0u;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glStencilMask(value));
}
@@ -65,7 +65,7 @@ struct StencilMask {
struct DepthMask {
using Type = GLboolean;
- static const Type Default;
+ static const constexpr Type Default = GL_TRUE;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glDepthMask(value));
}
@@ -78,7 +78,7 @@ struct DepthMask {
struct ColorMask {
struct Type { bool r, g, b, a; };
- static const Type Default;
+ static const constexpr Type Default = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glColorMask(value.r, value.g, value.b, value.a));
}
@@ -96,7 +96,7 @@ constexpr bool operator!=(const ColorMask::Type& a, const ColorMask::Type& b) {
struct StencilFunc {
struct Type { GLenum func; GLint ref; GLuint mask; };
- static const Type Default;
+ static const constexpr Type Default = { GL_ALWAYS, 0, ~0u };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glStencilFunc(value.func, value.ref, value.mask));
}
@@ -115,7 +115,7 @@ constexpr bool operator!=(const StencilFunc::Type& a, const StencilFunc::Type& b
struct StencilTest {
using Type = bool;
- static const Type Default;
+ static const constexpr Type Default = GL_FALSE;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_STENCIL_TEST) : glDisable(GL_STENCIL_TEST));
}
@@ -128,7 +128,7 @@ struct StencilTest {
struct StencilOp {
struct Type { GLenum sfail, dpfail, dppass; };
- static const Type Default;
+ static const constexpr Type Default = { GL_KEEP, GL_KEEP, GL_REPLACE };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glStencilOp(value.sfail, value.dpfail, value.dppass));
}
@@ -147,7 +147,7 @@ constexpr bool operator!=(const StencilOp::Type& a, const StencilOp::Type& b) {
struct DepthRange {
struct Type { GLfloat near, far; };
- static const Type Default;
+ static const constexpr Type Default = { 0, 1 };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glDepthRange(value.near, value.far));
}
@@ -164,7 +164,7 @@ constexpr bool operator!=(const DepthRange::Type& a, const DepthRange::Type& b)
struct DepthTest {
using Type = bool;
- static const Type Default;
+ static const constexpr Type Default = GL_FALSE;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST));
}
@@ -177,7 +177,7 @@ struct DepthTest {
struct DepthFunc {
using Type = GLenum;
- static const Type Default;
+ static const constexpr Type Default = GL_LEQUAL;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glDepthFunc(value));
}
@@ -190,7 +190,7 @@ struct DepthFunc {
struct Blend {
using Type = bool;
- static const Type Default;
+ static const constexpr Type Default = GL_TRUE;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_BLEND) : glDisable(GL_BLEND));
}
@@ -203,7 +203,7 @@ struct Blend {
struct BlendFunc {
struct Type { GLenum sfactor, dfactor; };
- static const Type Default;
+ static const constexpr Type Default = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glBlendFunc(value.sfactor, value.dfactor));
}
@@ -221,7 +221,7 @@ constexpr bool operator!=(const BlendFunc::Type& a, const BlendFunc::Type& b) {
struct BlendColor {
using Type = Color;
- static const Type Default;
+ static const constexpr Type Default = { 0, 0, 0, 0 };
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glBlendColor(value.r, value.g, value.b, value.a));
}
@@ -234,7 +234,7 @@ struct BlendColor {
struct Program {
using Type = GLuint;
- static const Type Default;
+ static const constexpr Type Default = 0;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glUseProgram(value));
}
@@ -247,7 +247,7 @@ struct Program {
struct LineWidth {
using Type = GLfloat;
- static const Type Default;
+ static const constexpr Type Default = 1;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glLineWidth(value));
}
@@ -260,7 +260,7 @@ struct LineWidth {
struct ActiveTexture {
using Type = uint8_t;
- static const Type Default;
+ static const constexpr Type Default = 0;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glActiveTexture(GL_TEXTURE0 + value));
}
@@ -275,7 +275,7 @@ struct ActiveTexture {
struct PixelZoom {
struct Type { GLfloat xfactor; GLfloat yfactor; };
- static const Type Default;
+ static const constexpr Type Default = { 1, 1 };
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glPixelZoom(value.xfactor, value.yfactor));
}
@@ -293,7 +293,7 @@ constexpr bool operator!=(const PixelZoom::Type& a, const PixelZoom::Type& b) {
struct RasterPos {
using Type = std::array<GLdouble, 4>;
- static const Type Default;
+ static const constexpr Type Default = {{ 0, 0, 0, 0 }};
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glRasterPos4d(value[0], value[1], value[2], value[3]));
}
@@ -308,7 +308,7 @@ struct RasterPos {
struct BindTexture {
using Type = GLuint;
- static const Type Default;
+ static const constexpr Type Default = 0;
static void Set(const Type& value) {
MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, value));
}
diff --git a/src/mbgl/gl/gl_config.cpp b/src/mbgl/gl/gl_config.cpp
deleted file mode 100644
index 9031c3d34f..0000000000
--- a/src/mbgl/gl/gl_config.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "gl_config.hpp"
-
-namespace mbgl {
-namespace gl {
-
-const StencilFunc::Type StencilFunc::Default = { GL_ALWAYS, 0, ~0u };
-const StencilMask::Type StencilMask::Default = ~0u;
-const StencilTest::Type StencilTest::Default = GL_FALSE;
-const StencilOp::Type StencilOp::Default = { GL_KEEP, GL_KEEP, GL_REPLACE };
-const DepthRange::Type DepthRange::Default = { 0, 1 };
-const DepthMask::Type DepthMask::Default = GL_TRUE;
-const DepthTest::Type DepthTest::Default = GL_FALSE;
-const DepthFunc::Type DepthFunc::Default = GL_LEQUAL;
-const Blend::Type Blend::Default = GL_TRUE;
-const BlendFunc::Type BlendFunc::Default = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
-const BlendColor::Type BlendColor::Default = { 0, 0, 0, 0 };
-const ColorMask::Type ColorMask::Default = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
-const ClearDepth::Type ClearDepth::Default = 1;
-const ClearColor::Type ClearColor::Default = { 0, 0, 0, 0 };
-const ClearStencil::Type ClearStencil::Default = 0;
-const Program::Type Program::Default = 0;
-const LineWidth::Type LineWidth::Default = 1;
-const ActiveTexture::Type ActiveTexture::Default = 0;
-const BindTexture::Type BindTexture::Default = 0;
-
-#ifndef GL_ES_VERSION_2_0
-const PixelZoom::Type PixelZoom::Default = { 1, 1 };
-const RasterPos::Type RasterPos::Default = {{ 0, 0, 0, 0 }};
-#endif // GL_ES_VERSION_2_0
-
-} // namespace gl
-} // namespace mbgl
diff --git a/src/mbgl/gl/gl_values.cpp b/src/mbgl/gl/gl_values.cpp
new file mode 100644
index 0000000000..04a3026e24
--- /dev/null
+++ b/src/mbgl/gl/gl_values.cpp
@@ -0,0 +1,32 @@
+#include <mbgl/gl/gl_values.hpp>
+
+namespace mbgl {
+namespace gl {
+
+const constexpr StencilFunc::Type StencilFunc::Default;
+const constexpr StencilMask::Type StencilMask::Default;
+const constexpr StencilTest::Type StencilTest::Default;
+const constexpr StencilOp::Type StencilOp::Default;
+const constexpr DepthRange::Type DepthRange::Default;
+const constexpr DepthMask::Type DepthMask::Default;
+const constexpr DepthTest::Type DepthTest::Default;
+const constexpr DepthFunc::Type DepthFunc::Default;
+const constexpr Blend::Type Blend::Default;
+const constexpr BlendFunc::Type BlendFunc::Default;
+const constexpr BlendColor::Type BlendColor::Default;
+const constexpr ColorMask::Type ColorMask::Default;
+const constexpr ClearDepth::Type ClearDepth::Default;
+const constexpr ClearColor::Type ClearColor::Default;
+const constexpr ClearStencil::Type ClearStencil::Default;
+const constexpr Program::Type Program::Default;
+const constexpr LineWidth::Type LineWidth::Default;
+const constexpr ActiveTexture::Type ActiveTexture::Default;
+const constexpr BindTexture::Type BindTexture::Default;
+
+#ifndef GL_ES_VERSION_2_0
+const constexpr PixelZoom::Type PixelZoom::Default;
+const constexpr RasterPos::Type RasterPos::Default;
+#endif // GL_ES_VERSION_2_0
+
+} // namespace gl
+} // namespace mbgl