From f1ac757bd28351fd57113a1e16f6c2e00ab193c1 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 11 Jul 2017 15:11:14 +0300 Subject: [core] GCC 4.9 does not fully support custom variable templates --- src/mbgl/gl/attribute.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/mbgl/gl/attribute.cpp') 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 DataType DataTypeOf = static_cast(0); -template <> DataType DataTypeOf< int8_t> = DataType::Byte; -template <> DataType DataTypeOf = DataType::UnsignedByte; -template <> DataType DataTypeOf< int16_t> = DataType::Short; -template <> DataType DataTypeOf = DataType::UnsignedShort; -template <> DataType DataTypeOf< int32_t> = DataType::Integer; -template <> DataType DataTypeOf = DataType::UnsignedInteger; -template <> DataType DataTypeOf = DataType::Float; +template +constexpr DataType DataTypeOf() { + return std::is_same::value ? DataType::Byte : + std::is_same::value ? DataType::UnsignedByte : + std::is_same::value ? DataType::Short : + std::is_same::value ? DataType::UnsignedShort : + std::is_same::value ? DataType::Integer : + std::is_same::value ? DataType::UnsignedInteger : + std::is_same::value ? DataType::Float : static_cast(0); +} template void AttributeBinding::bind(Context& context, AttributeLocation location, std::size_t vertexOffset) const { @@ -76,7 +78,7 @@ void AttributeBinding::bind(Context& context, AttributeLocation location, MBGL_CHECK_ERROR(glVertexAttribPointer( location, static_cast(attributeSize), - static_cast(DataTypeOf), + static_cast(DataTypeOf()), static_cast(false), static_cast(vertexSize), reinterpret_cast(attributeOffset + (vertexSize * vertexOffset)))); -- cgit v1.2.1