summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-07-11 15:11:14 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-07-12 20:42:29 +0300
commitf1ac757bd28351fd57113a1e16f6c2e00ab193c1 (patch)
treea68be48a2c6934c11fbda3efbc6077c45e703906 /src
parent1aacc88f350d2d54337cdacb1a653785c759586b (diff)
downloadqtlocation-mapboxgl-f1ac757bd28351fd57113a1e16f6c2e00ab193c1.tar.gz
[core] GCC 4.9 does not fully support custom variable templates
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/gl/attribute.cpp20
-rw-r--r--src/mbgl/gl/attribute.hpp5
2 files changed, 12 insertions, 13 deletions
diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp
index 4e6f78e689..4569e3cb32 100644
--- a/src/mbgl/gl/attribute.cpp
+++ b/src/mbgl/gl/attribute.cpp
@@ -55,14 +55,16 @@ void DisabledAttribute::bind(Context&, AttributeLocation location, std::size_t)
MBGL_CHECK_ERROR(glDisableVertexAttribArray(location));
}
-template <class T> DataType DataTypeOf = static_cast<DataType>(0);
-template <> DataType DataTypeOf< int8_t> = DataType::Byte;
-template <> DataType DataTypeOf<uint8_t> = DataType::UnsignedByte;
-template <> DataType DataTypeOf< int16_t> = DataType::Short;
-template <> DataType DataTypeOf<uint16_t> = DataType::UnsignedShort;
-template <> DataType DataTypeOf< int32_t> = DataType::Integer;
-template <> DataType DataTypeOf<uint32_t> = DataType::UnsignedInteger;
-template <> DataType DataTypeOf<float> = DataType::Float;
+template <class T>
+constexpr DataType DataTypeOf() {
+ return std::is_same<T, int8_t>::value ? DataType::Byte :
+ std::is_same<T, uint8_t>::value ? DataType::UnsignedByte :
+ std::is_same<T, int16_t>::value ? DataType::Short :
+ std::is_same<T, uint16_t>::value ? DataType::UnsignedShort :
+ std::is_same<T, int32_t>::value ? DataType::Integer :
+ std::is_same<T, uint32_t>::value ? DataType::UnsignedInteger :
+ std::is_same<T, float>::value ? DataType::Float : static_cast<DataType>(0);
+}
template <class T, std::size_t N>
void AttributeBinding<T, N>::bind(Context& context, AttributeLocation location, std::size_t vertexOffset) const {
@@ -76,7 +78,7 @@ void AttributeBinding<T, N>::bind(Context& context, AttributeLocation location,
MBGL_CHECK_ERROR(glVertexAttribPointer(
location,
static_cast<GLint>(attributeSize),
- static_cast<GLenum>(DataTypeOf<T>),
+ static_cast<GLenum>(DataTypeOf<T>()),
static_cast<GLboolean>(false),
static_cast<GLsizei>(vertexSize),
reinterpret_cast<GLvoid*>(attributeOffset + (vertexSize * vertexOffset))));
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index f018a1d261..bc02b54bd2 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -240,9 +240,6 @@ public:
using Vertex = detail::Vertex<typename As::Type...>;
- template <class A>
- static constexpr std::size_t Index = TypeIndex<A, As...>::value;
-
static Locations bindLocations(const ProgramID& id) {
std::set<std::string> activeAttributes = getActiveAttributes(id);
@@ -266,7 +263,7 @@ public:
template <class DrawMode>
static Bindings bindings(const VertexBuffer<Vertex, DrawMode>& buffer) {
- return Bindings { As::Type::binding(buffer, Index<As>)... };
+ return Bindings { As::Type::binding(buffer, TypeIndex<As, As...>::value)... };
}
static void bind(Context& context,