summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/attribute.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/attribute.hpp')
-rw-r--r--src/mbgl/gl/attribute.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index 48222146fa..f018a1d261 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -8,6 +8,7 @@
#include <cstddef>
#include <vector>
+#include <set>
#include <functional>
namespace mbgl {
@@ -223,6 +224,7 @@ const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = {
} // namespace detail
AttributeLocation bindAttributeLocation(ProgramID, AttributeLocation, const char * name);
+std::set<std::string> getActiveAttributes(ProgramID);
template <class... As>
class Attributes {
@@ -242,7 +244,15 @@ public:
static constexpr std::size_t Index = TypeIndex<A, As...>::value;
static Locations bindLocations(const ProgramID& id) {
- return Locations { bindAttributeLocation(id, Index<As>, As::name())... };
+ std::set<std::string> activeAttributes = getActiveAttributes(id);
+
+ AttributeLocation location = -1;
+ auto bindAndIncrement = [&](const char* name) {
+ location++;
+ return bindAttributeLocation(id, location, name);
+ };
+ return Locations{ (activeAttributes.count(As::name()) ? bindAndIncrement(As::name())
+ : -1)... };
}
template <class Program>