summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-03 14:05:12 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-12 14:43:23 -0700
commitfedfaa2f6e582e87b190f5d423302f9f95d147d9 (patch)
tree55e14f03559c8388d112422c18b80b6d68247a2d /src
parent8fb212dbb3f43c51f75747629db5c39f44b0c28a (diff)
downloadqtlocation-mapboxgl-fedfaa2f6e582e87b190f5d423302f9f95d147d9.tar.gz
[core] Inline getActiveAttributes details
Diffstat (limited to 'src')
-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 4569e3cb32..5583cfd916 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;