From 105561ad77e155453d42490875399fd7cab051af Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 2 Apr 2025 15:05:36 +0300 Subject: [PATCH] refactor GLFWWindow --- src/window/detail/GLFWWindow.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index 180707b3..dbb0c636 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -18,20 +18,16 @@ static debug::Logger logger("window"); -static std::unordered_set extensions_cache; - -static void init_gl_extensions_cache() { - if (!extensions_cache.empty()) { - return; - } +static std::unordered_set supported_gl_extensions; +static void init_gl_extensions_list() { GLint numExtensions = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); for (GLint i = 0; i < numExtensions; ++i) { const char *ext = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); if (ext) { - extensions_cache.insert(ext); + supported_gl_extensions.insert(ext); } } } @@ -40,8 +36,7 @@ static bool is_gl_extension_supported(const char *extension) { if (!extension || !*extension) { return false; } - init_gl_extensions_cache(); - return extensions_cache.find(extension) != extensions_cache.end(); + return supported_gl_extensions.find(extension) != supported_gl_extensions.end(); } static const char* gl_error_name(int error) { @@ -669,6 +664,7 @@ std::tuple< } } + init_gl_extensions_list(); if (is_gl_extension_supported("GL_KHR_debug")) { glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(gl_message_callback, nullptr);