summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/value.cpp')
-rw-r--r--src/mbgl/gl/value.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index 2b825fb2bd..092403af0d 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -242,13 +242,13 @@ LineWidth::Type LineWidth::Get() {
return lineWidth;
}
-const constexpr ActiveTexture::Type ActiveTexture::Default;
+const constexpr ActiveTextureUnit::Type ActiveTextureUnit::Default;
-void ActiveTexture::Set(const Type& value) {
+void ActiveTextureUnit::Set(const Type& value) {
MBGL_CHECK_ERROR(glActiveTexture(GL_TEXTURE0 + value));
}
-ActiveTexture::Type ActiveTexture::Get() {
+ActiveTextureUnit::Type ActiveTextureUnit::Get() {
GLint activeTexture;
MBGL_CHECK_ERROR(glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture));
return static_cast<Type>(activeTexture - GL_TEXTURE0);
@@ -365,6 +365,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));
+ }
+}
+
const constexpr PixelStorePack::Type PixelStorePack::Default;
void PixelStorePack::Set(const Type& value) {