From fedfaa2f6e582e87b190f5d423302f9f95d147d9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Jul 2017 14:05:12 -0700 Subject: [core] Inline getActiveAttributes details --- src/mbgl/gl/attribute.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'src') 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 getActiveAttributes(ProgramID id) { + std::set 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(location), - static_cast(maxLength), &actualLength, &size, &type, - const_cast(attributeName.data()))); - attributeName.resize(actualLength); - return attributeName; -} - -std::set getActiveAttributes(ProgramID id) { - std::set 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; -- cgit v1.2.1