#include #include #include #include namespace mbgl { namespace gl { static_assert(offsetof(Normalized, value) == 0, "unexpected normalized offset"); AttributeLocation bindAttributeLocation(ProgramID id, AttributeLocation location, const char* name) { MBGL_CHECK_ERROR(glBindAttribLocation(id, location, name)); return 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 bool IsNormalized = false; template bool IsNormalized> = true; template DataType DataTypeOf> = DataTypeOf; template void VariableAttributeBinding::bind(Context& context, AttributeLocation location, optional>& oldBinding, std::size_t vertexOffset) const { if (oldBinding == *this) { return; } context.vertexBuffer = vertexBuffer; MBGL_CHECK_ERROR(glEnableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttribPointer( location, static_cast(N), static_cast(DataTypeOf), static_cast(IsNormalized), static_cast(vertexSize), reinterpret_cast(attributeOffset + (vertexSize * vertexOffset)))); } template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding, 1>; template class VariableAttributeBinding, 2>; template class VariableAttributeBinding, 3>; template class VariableAttributeBinding, 4>; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template class VariableAttributeBinding; template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib1f(location, value[0])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib2f(location, value[0], value[1])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib3f(location, value[0], value[1], value[2])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib4f(location, value[0], value[1], value[2], value[3])); } template <> void ConstantAttributeBinding, 1>::bind(Context&, AttributeLocation location, optional, 1>>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib1f(location, value[0].denormalized())); } template <> void ConstantAttributeBinding, 2>::bind(Context&, AttributeLocation location, optional, 2>>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib2f(location, value[0].denormalized(), value[1].denormalized())); } template <> void ConstantAttributeBinding, 3>::bind(Context&, AttributeLocation location, optional, 3>>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib3f(location, value[0].denormalized(), value[1].denormalized(), value[2].denormalized())); } template <> void ConstantAttributeBinding, 4>::bind(Context&, AttributeLocation location, optional, 4>>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib4f(location, value[0].denormalized(), value[1].denormalized(), value[2].denormalized(), value[3].denormalized())); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib1f(location, value[0])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib2f(location, value[0], value[1])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib3f(location, value[0], value[1], value[2])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib4f(location, value[0], value[1], value[2], value[3])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib1f(location, value[0])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib2f(location, value[0], value[1])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib3f(location, value[0], value[1], value[2])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib4f(location, value[0], value[1], value[2], value[3])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib1f(location, value[0])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib2f(location, value[0], value[1])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib3f(location, value[0], value[1], value[2])); } template <> void ConstantAttributeBinding::bind(Context&, AttributeLocation location, optional>& oldBinding, std::size_t) const { assert(location != 0); oldBinding = {}; MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); MBGL_CHECK_ERROR(glVertexAttrib4f(location, value[0], value[1], value[2], value[3])); } } // namespace gl } // namespace mbgl