summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-03-12 16:51:54 +0100
committerKonstantin Käfer <mail@kkaefer.com>2019-03-15 11:55:28 +0100
commitdb813c1c0927d10fac704c79de13bd94c1315bb1 (patch)
tree53344e88839310d6c78c859921a206f6155b10cf
parent982e76faccffbe275120c24726a555cfffb79520 (diff)
downloadqtlocation-mapboxgl-db813c1c0927d10fac704c79de13bd94c1315bb1.tar.gz
[core] move attributeBinding function to gfx namespace
-rw-r--r--src/mbgl/gfx/attribute.hpp14
-rw-r--r--src/mbgl/gl/attribute.hpp19
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp10
3 files changed, 18 insertions, 25 deletions
diff --git a/src/mbgl/gfx/attribute.hpp b/src/mbgl/gfx/attribute.hpp
index f1795d4653..070efbaafa 100644
--- a/src/mbgl/gfx/attribute.hpp
+++ b/src/mbgl/gfx/attribute.hpp
@@ -248,13 +248,23 @@ public:
template <class A>
using Vertex = typename detail::Vertex<A>::Type;
-template <class V>
-using VertexDescriptorOf = detail::Descriptor<V>;
template <class T>
using VertexType = typename detail::VertexType<T>;
template <class AttributeTypeList>
using AttributeBindings = typename detail::AttributeBindings<AttributeTypeList>::Type;
+template <size_t I = 0, class... As>
+AttributeBinding attributeBinding(const VertexBuffer<detail::VertexType<As...>>& buffer) {
+ using Descriptor = detail::Descriptor<detail::VertexType<As...>>;
+ static_assert(I < Descriptor::data.count, "attribute index must be in range");
+ return {
+ Descriptor::data.attributes[I],
+ Descriptor::data.stride,
+ buffer.resource.get(),
+ 0,
+ };
+}
+
} // namespace gfx
} // namespace mbgl
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index 60a98ad563..5fe0340d9c 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -20,23 +20,6 @@ namespace gl {
using AttributeBindingArray = std::vector<optional<gfx::AttributeBinding>>;
-
- /*
- Create a binding for this attribute. The `attributeSize` parameter may be used to
- override the number of components available in the buffer for each vertex. Thus,
- a buffer with only one float for each vertex can be bound to a `vec2` attribute
- */
-template <std::size_t I, typename Vertex>
-gfx::AttributeBinding attributeBinding(const gfx::VertexBuffer<Vertex>& buffer) {
- static_assert(I < gfx::VertexDescriptorOf<Vertex>::data.count, "vertex attribute index out of range");
- return {
- gfx::VertexDescriptorOf<Vertex>::data.attributes[I],
- gfx::VertexDescriptorOf<Vertex>::data.stride,
- buffer.resource.get(),
- 0,
- };
-}
-
optional<gfx::AttributeBinding> offsetAttributeBinding(const optional<gfx::AttributeBinding>& binding, std::size_t vertexOffset);
class Context;
@@ -92,7 +75,7 @@ public:
}
static Bindings bindings(const gfx::VertexBuffer<gfx::Vertex<Types>>& buffer) {
- return Bindings { attributeBinding<TypeIndex<As, As...>::value>(buffer)... };
+ return Bindings { gfx::attributeBinding<TypeIndex<As, As...>::value>(buffer)... };
}
static Bindings offsetBindings(const Bindings& bindings, std::size_t vertexOffset) {
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp
index 99d51ba4cc..06e69f2f28 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -2,8 +2,8 @@
#include <mbgl/gfx/context.hpp>
#include <mbgl/gfx/uniform.hpp>
+#include <mbgl/gfx/attribute.hpp>
#include <mbgl/programs/attributes.hpp>
-#include <mbgl/gl/attribute.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/type_list.hpp>
#include <mbgl/renderer/possibly_evaluated_property_value.hpp>
@@ -205,7 +205,7 @@ public:
return {};
} else {
return std::tuple<optional<gfx::AttributeBinding>>{
- gl::attributeBinding<0>(*vertexBuffer)
+ gfx::attributeBinding(*vertexBuffer)
};
}
}
@@ -269,7 +269,7 @@ public:
return {};
} else {
return std::tuple<optional<gfx::AttributeBinding>>{
- gl::attributeBinding<0>(*vertexBuffer)
+ gfx::attributeBinding(*vertexBuffer)
};
}
}
@@ -363,8 +363,8 @@ public:
return {};
} else {
return std::tuple<optional<gfx::AttributeBinding>, optional<gfx::AttributeBinding>>{
- gl::attributeBinding<0>(*patternToVertexBuffer),
- gl::attributeBinding<0>(crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer)
+ gfx::attributeBinding(*patternToVertexBuffer),
+ gfx::attributeBinding(crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer)
};
}
}