summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/gl/attribute.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp
index 4e6f78e689..2f817cdcd8 100644
--- a/src/mbgl/gl/attribute.cpp
+++ b/src/mbgl/gl/attribute.cpp
@@ -13,39 +13,25 @@ AttributeLocation bindAttributeLocation(ProgramID id, AttributeLocation location
return location;
}
-int32_t getActiveAttributeCount(ProgramID id) {
- GLint numAttributes;
- MBGL_CHECK_ERROR(glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, &numAttributes));
- return numAttributes;
-}
+std::set<std::string> getActiveAttributes(ProgramID id) {
+ std::set<std::string> activeAttributes;
-int32_t getMaxAttributeNameLength(ProgramID id) {
- GLint nameLength;
- MBGL_CHECK_ERROR(glGetProgramiv(id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &nameLength));
- return nameLength;
-}
+ GLint attributeCount;
+ MBGL_CHECK_ERROR(glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, &attributeCount));
+
+ GLint maxAttributeLength;
+ MBGL_CHECK_ERROR(glGetProgramiv(id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeLength));
-std::string getAttributeName(ProgramID id, int32_t maxLength, AttributeLocation location) {
std::string attributeName;
- attributeName.resize(maxLength);
+ attributeName.resize(maxAttributeLength);
+
GLsizei actualLength;
GLint size;
GLenum type;
- MBGL_CHECK_ERROR(glGetActiveAttrib(id, static_cast<GLuint>(location),
- static_cast<GLsizei>(maxLength), &actualLength, &size, &type,
- const_cast<char*>(attributeName.data())));
- attributeName.resize(actualLength);
- return attributeName;
-}
-
-std::set<std::string> getActiveAttributes(ProgramID id) {
- std::set<std::string> activeAttributes;
-
- GLint attributeCount = getActiveAttributeCount(id);
- GLint maxAttributeLength = getMaxAttributeNameLength(id);
for (int32_t i = 0; i < attributeCount; i++) {
- activeAttributes.emplace(getAttributeName(id, maxAttributeLength, i));
+ MBGL_CHECK_ERROR(glGetActiveAttrib(id, i, maxAttributeLength, &actualLength, &size, &type, &attributeName[0]));
+ activeAttributes.emplace(std::string(attributeName, 0, actualLength));
}
return activeAttributes;