diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-02 17:43:51 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-05 10:52:19 -0700 |
commit | e4310aa87489c2db52d7ff65f71e51cc6c9700b6 (patch) | |
tree | 438e67108779aac6f8787ef7b03644534955bf1f /include | |
parent | b9b8657d43aa1172e9ca6be162e915006806ee57 (diff) | |
download | qtlocation-mapboxgl-e4310aa87489c2db52d7ff65f71e51cc6c9700b6.tar.gz |
[core] Improve attribute binding API
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/gl/gl.hpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/include/mbgl/gl/gl.hpp b/include/mbgl/gl/gl.hpp index c826e1f4e8..b3c2d83a5e 100644 --- a/include/mbgl/gl/gl.hpp +++ b/include/mbgl/gl/gl.hpp @@ -1,9 +1,6 @@ #pragma once -#include <mbgl/gl/types.hpp> - #include <stdexcept> -#include <type_traits> #include <limits> #if __APPLE__ @@ -46,34 +43,5 @@ void checkError(const char *cmd, const char *file, int line); #define MBGL_CHECK_ERROR(cmd) (cmd) #endif -template <typename T> struct AttributeType; - -template <> struct AttributeType<int8_t> : std::integral_constant<GLenum, GL_BYTE> {}; -template <> struct AttributeType<uint8_t> : std::integral_constant<GLenum, GL_UNSIGNED_BYTE> {}; -template <> struct AttributeType<int16_t> : std::integral_constant<GLenum, GL_SHORT> {}; -template <> struct AttributeType<uint16_t> : std::integral_constant<GLenum, GL_UNSIGNED_SHORT> {}; -template <> struct AttributeType<int32_t> : std::integral_constant<GLenum, GL_INT> {}; -template <> struct AttributeType<uint32_t> : std::integral_constant<GLenum, GL_UNSIGNED_INT> {}; -template <> struct AttributeType<float> : std::integral_constant<GLenum, GL_FLOAT> {}; - -template <std::size_t memberOffset, class V, class E, std::size_t N> -void bindVertexAttribute(AttributeLocation location, const E (V::*)[N], const int8_t* offset) { - static_assert(std::is_standard_layout<V>::value, "vertex type must use standard layout"); - static_assert(memberOffset % 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(V) <= std::numeric_limits<GLsizei>::max(), "vertex type is too big"); - MBGL_CHECK_ERROR(glEnableVertexAttribArray(location)); - MBGL_CHECK_ERROR(glVertexAttribPointer(location, - static_cast<GLint>(N), - AttributeType<E>::value, - false, - static_cast<GLsizei>(sizeof(V)), - offset + memberOffset)); -} - -// This has to be a macro because it uses the offsetof macro, which is the only legal way to get a member offset. -#define MBGL_BIND_VERTEX_ATTRIBUTE(VertexType, member, offset) \ - ::mbgl::gl::bindVertexAttribute<offsetof(VertexType, member)>(gl::Shader::member, &VertexType::member, offset) - } // namespace gl } // namespace mbgl |