mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 23:11:49 +00:00
refactor GLFWWindow
This commit is contained in:
parent
45ccf893ae
commit
105561ad77
1 changed files with 5 additions and 9 deletions
|
|
@ -18,20 +18,16 @@
|
||||||
|
|
||||||
static debug::Logger logger("window");
|
static debug::Logger logger("window");
|
||||||
|
|
||||||
static std::unordered_set<std::string> extensions_cache;
|
static std::unordered_set<std::string> supported_gl_extensions;
|
||||||
|
|
||||||
static void init_gl_extensions_cache() {
|
|
||||||
if (!extensions_cache.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static void init_gl_extensions_list() {
|
||||||
GLint numExtensions = 0;
|
GLint numExtensions = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
||||||
|
|
||||||
for (GLint i = 0; i < numExtensions; ++i) {
|
for (GLint i = 0; i < numExtensions; ++i) {
|
||||||
const char *ext = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
|
const char *ext = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
|
||||||
if (ext) {
|
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) {
|
if (!extension || !*extension) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
init_gl_extensions_cache();
|
return supported_gl_extensions.find(extension) != supported_gl_extensions.end();
|
||||||
return extensions_cache.find(extension) != extensions_cache.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* gl_error_name(int error) {
|
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")) {
|
if (is_gl_extension_supported("GL_KHR_debug")) {
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glDebugMessageCallback(gl_message_callback, nullptr);
|
glDebugMessageCallback(gl_message_callback, nullptr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue