diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 1642318b1..2f88d43c8 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -646,7 +646,7 @@ bool Context::tryCreate() { /* Mark all extensions from past versions as supported */ for(std::size_t i = 0; i != future; ++i) for(const Extension& extension: Extension::extensions(versions[i])) - _extensionStatus.set(extension._index); + _extensionStatus.set(extension.index()); /* List of extensions from future versions (extensions from current and previous versions should be supported automatically, so we don't need @@ -654,7 +654,7 @@ bool Context::tryCreate() { std::unordered_map futureExtensions; for(std::size_t i = future; i != versions.size(); ++i) for(const Extension& extension: Extension::extensions(versions[i])) - futureExtensions.emplace(extension._string, extension); + futureExtensions.emplace(extension.string(), extension); /* Check for presence of future and vendor extensions */ const std::vector extensions = extensionStrings(); @@ -662,7 +662,7 @@ bool Context::tryCreate() { const auto found = futureExtensions.find(extension); if(found != futureExtensions.end()) { _supportedExtensions.push_back(found->second); - _extensionStatus.set(found->second._index); + _extensionStatus.set(found->second.index()); } } @@ -672,7 +672,7 @@ bool Context::tryCreate() { /* Initialize required versions from extension info */ for(const auto version: versions) for(const Extension& extension: Extension::extensions(version)) - _extensionRequiredVersion[extension._index] = extension._requiredVersion; + _extensionRequiredVersion[extension.index()] = extension.requiredVersion(); /* Setup driver workarounds (increase required version for particular extensions), see Implementation/driverWorkarounds.cpp */ @@ -698,7 +698,7 @@ bool Context::tryCreate() { std::unordered_map allExtensions{std::move(futureExtensions)}; for(std::size_t i = 0; i != future; ++i) for(const Extension& extension: Extension::extensions(versions[i])) - allExtensions.emplace(extension._string, extension); + allExtensions.emplace(extension.string(), extension); /* Disable extensions that are known and supported and print a message for each */ @@ -707,7 +707,7 @@ bool Context::tryCreate() { /** @todo Error message here? I should not clutter the output at this point */ if(found == allExtensions.end()) continue; - _extensionRequiredVersion[found->second._index] = Version::None; + _extensionRequiredVersion[found->second.index()] = Version::None; Debug{output} << " " << extension; } } diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 3c2a4577c..a78282bea 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -64,6 +64,9 @@ class MAGNUM_EXPORT Extension { /** @brief All extensions for given OpenGL version */ static const std::vector& extensions(Version version); + /** @brief Internal unique extension index */ + constexpr std::size_t index() const { return _index; } + /** @brief Minimal version required by this extension */ constexpr Version requiredVersion() const { return _requiredVersion; } @@ -74,10 +77,6 @@ class MAGNUM_EXPORT Extension { constexpr const char* string() const { return _string; } private: - #ifndef DOXYGEN_GENERATING_OUTPUT /* https://bugzilla.gnome.org/show_bug.cgi?id=776986 */ - friend Context; - #endif - std::size_t _index; Version _requiredVersion; Version _coreVersion; @@ -541,7 +540,7 @@ class MAGNUM_EXPORT Context { * @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() */ bool isExtensionSupported(const Extension& extension) const { - return isVersionSupported(_extensionRequiredVersion[extension._index]) && _extensionStatus[extension._index]; + return isVersionSupported(_extensionRequiredVersion[extension.index()]) && _extensionStatus[extension.index()]; } /** @@ -574,7 +573,7 @@ class MAGNUM_EXPORT Context { * as it does most operations in compile time. */ bool isExtensionDisabled(const Extension& extension) const { - return isVersionSupported(extension._requiredVersion) && !isVersionSupported(_extensionRequiredVersion[extension._index]); + return isVersionSupported(extension.requiredVersion()) && !isVersionSupported(_extensionRequiredVersion[extension.index()]); } /**