diff options
Diffstat (limited to 'src/mbgl/gl/value.cpp')
-rw-r--r-- | src/mbgl/gl/value.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index c081c941f5..10818e8499 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -353,6 +353,24 @@ BindVertexArray::Type BindVertexArray::Get(const Context& context) { return binding; } +const optional<AttributeBinding> VertexAttribute::Default {}; + +void VertexAttribute::Set(const optional<AttributeBinding>& binding, Context& context, AttributeLocation location) { + if (binding) { + context.vertexBuffer = binding->vertexBuffer; + MBGL_CHECK_ERROR(glEnableVertexAttribArray(location)); + MBGL_CHECK_ERROR(glVertexAttribPointer( + location, + static_cast<GLint>(binding->attributeSize), + static_cast<GLenum>(binding->attributeType), + static_cast<GLboolean>(false), + static_cast<GLsizei>(binding->vertexSize), + reinterpret_cast<GLvoid*>(binding->attributeOffset + (binding->vertexSize * binding->vertexOffset)))); + } else { + MBGL_CHECK_ERROR(glDisableVertexAttribArray(location)); + } +} + #if not MBGL_USE_GLES2 const constexpr PointSize::Type PointSize::Default; |