summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/context.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-10-02 17:43:51 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-10-05 10:52:19 -0700
commite4310aa87489c2db52d7ff65f71e51cc6c9700b6 (patch)
tree438e67108779aac6f8787ef7b03644534955bf1f /src/mbgl/gl/context.hpp
parentb9b8657d43aa1172e9ca6be162e915006806ee57 (diff)
downloadqtlocation-mapboxgl-e4310aa87489c2db52d7ff65f71e51cc6c9700b6.tar.gz
[core] Improve attribute binding API
Diffstat (limited to 'src/mbgl/gl/context.hpp')
-rw-r--r--src/mbgl/gl/context.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index e26b35e7c0..6a5d44793a 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -6,6 +6,7 @@
#include <mbgl/gl/texture.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
+#include <mbgl/gl/attribute.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <memory>
@@ -60,6 +61,14 @@ public:
TextureFilter = TextureFilter::Nearest,
TextureMipMap = TextureMipMap::No);
+ template <class Shader, class Vertex>
+ void bindAttributes(const Shader& shader, const VertexBuffer<Vertex>&, const int8_t* offset) {
+ static_assert(std::is_same<typename Shader::VertexType, Vertex>::value, "vertex type mismatch");
+ for (const auto& binding : AttributeBindings<Shader, Vertex>()(shader)) {
+ bindAttribute(binding, sizeof(Vertex), offset);
+ }
+ }
+
// Actually remove the objects we marked as abandoned with the above methods.
// Only call this while the OpenGL context is exclusive to this thread.
void performCleanup();
@@ -115,6 +124,7 @@ private:
UniqueBuffer createVertexBuffer(const void* data, std::size_t size);
UniqueBuffer createIndexBuffer(const void* data, std::size_t size);
UniqueTexture createTexture(uint16_t width, uint16_t height, const void* data, TextureUnit);
+ void bindAttribute(const AttributeBinding&, std::size_t stride, const int8_t* offset);
friend detail::ProgramDeleter;
friend detail::ShaderDeleter;