#pragma once #include #include #include #include #include namespace mbgl { namespace gl { template class Attribute { public: Attribute(const char* name, const Shader& shader) : location(shader.getAttributeLocation(name)) {} AttributeLocation location; }; class AttributeBinding { public: template AttributeBinding(const T (Vertex::*)[N], const Attribute& attribute, std::integral_constant) : location(attribute.location), type(DataTypeOf::value), count(N), offset(O) { static_assert(std::is_standard_layout::value, "vertex type must use standard layout"); static_assert(O % 4 == 0, "vertex attribute must be optimally aligned"); static_assert(1 <= N && N <= 4, "count must be 1, 2, 3, or 4"); static_assert(sizeof(Vertex) <= std::numeric_limits::max(), "vertex type is too big"); } AttributeLocation location; DataType type; uint8_t count; std::size_t offset; }; #define MBGL_MAKE_ATTRIBUTE_BINDING(Vertex, shader, name) \ ::mbgl::gl::AttributeBinding(&Vertex::name, \ shader.name, \ std::integral_constant()) template struct AttributeBindings; } // namespace gl } // namespace mbgl