summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl')
-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,