diff options
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/extension.cpp | 25 | ||||
-rw-r--r-- | src/mbgl/gl/extension.hpp | 7 |
2 files changed, 14 insertions, 18 deletions
diff --git a/src/mbgl/gl/extension.cpp b/src/mbgl/gl/extension.cpp index e6b4d9156e..41a5ea175e 100644 --- a/src/mbgl/gl/extension.cpp +++ b/src/mbgl/gl/extension.cpp @@ -1,7 +1,6 @@ #include <mbgl/gl/extension.hpp> #include <mbgl/gl/gl.hpp> -#include <mutex> #include <string> #include <vector> #include <cstring> @@ -11,7 +10,7 @@ namespace gl { namespace detail { using Probes = std::vector<ExtensionFunctionBase::Probe>; -using ExtensionFunctions = std::vector<std::pair<glProc*, Probes>>; +using ExtensionFunctions = std::vector<std::pair<ProcAddress*, Probes>>; ExtensionFunctions& extensionFunctions() { static ExtensionFunctions functions; return functions; @@ -23,22 +22,18 @@ ExtensionFunctionBase::ExtensionFunctionBase(std::initializer_list<Probe> probes } // namespace detail -static std::once_flag initializeExtensionsOnce; - -void InitializeExtensions(glProc (*getProcAddress)(const char*)) { - std::call_once(initializeExtensionsOnce, [getProcAddress] { - if (const char* extensions = - reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)))) { - for (auto fn : detail::extensionFunctions()) { - for (auto probe : fn.second) { - if (strstr(extensions, probe.first) != nullptr) { - *fn.first = getProcAddress(probe.second); - break; - } +void initializeExtensions(const std::function<ProcAddress(const char*)>& getProcAddress) { + if (const char* extensions = + reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)))) { + for (auto fn : detail::extensionFunctions()) { + for (auto probe : fn.second) { + if (strstr(extensions, probe.first) != nullptr) { + *fn.first = getProcAddress(probe.second); + break; } } } - }); + } } } // namespace gl diff --git a/src/mbgl/gl/extension.hpp b/src/mbgl/gl/extension.hpp index ea5a1ae5f5..7d1d9a4d7d 100644 --- a/src/mbgl/gl/extension.hpp +++ b/src/mbgl/gl/extension.hpp @@ -2,12 +2,13 @@ #include <initializer_list> #include <utility> +#include <functional> namespace mbgl { namespace gl { -using glProc = void (*)(); -void InitializeExtensions(glProc (*getProcAddress)(const char*)); +using ProcAddress = void (*)(); +void initializeExtensions(const std::function<ProcAddress(const char*)>&); namespace detail { @@ -15,7 +16,7 @@ class ExtensionFunctionBase { public: using Probe = std::pair<const char*, const char*>; ExtensionFunctionBase(std::initializer_list<Probe>); - glProc ptr; + ProcAddress ptr; }; } // namespace detail |