From 369b9b320b25958afb2bec4b18f8bce60be41c77 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Thu, 1 May 2025 22:18:48 +0800 Subject: [PATCH] [Improvement] (GL_Getter.*): Code improvement. --- .../Implementations/GL/Getter/GL_Getter.cpp | 23 +++++++------------ .../Implementations/GL/Getter/GL_Getter.h | 6 ++--- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/MG/MG_GL/Implementations/GL/Getter/GL_Getter.cpp b/MG/MG_GL/Implementations/GL/Getter/GL_Getter.cpp index 9a743df3..c43ce711 100644 --- a/MG/MG_GL/Implementations/GL/Getter/GL_Getter.cpp +++ b/MG/MG_GL/Implementations/GL/Getter/GL_Getter.cpp @@ -73,9 +73,6 @@ namespace MG_GL::GL { } StringCache; static StringCache caches[] = { {GL_EXTENSIONS, nullptr, 0}, - {GL_VENDOR, nullptr, 0}, - {GL_VERSION, nullptr, 0}, - {GL_SHADING_LANGUAGE_VERSION, nullptr, 0} }; static int initialized = 0; if (!initialized) { @@ -124,19 +121,15 @@ namespace MG_GL::GL { case GL_NUM_EXTENSIONS: static GLint num_extensions = -1; if (num_extensions == -1) { - const GLubyte* ext_str = glGetString(GL_EXTENSIONS); - if (ext_str) { - char* copy = strdup((const char*)ext_str); - char* token = strtok(copy, " "); - num_extensions = 0; - while (token) { - num_extensions++; - token = strtok(nullptr, " "); - } - free(copy); - } else { - num_extensions = 0; + const GLubyte* ext_str = MG_GL::GL::GetString(GL_EXTENSIONS); + char *copy = strdup((const char *) ext_str); + char *token = strtok(copy, " "); + num_extensions = 0; + while (token) { + num_extensions++; + token = strtok(nullptr, " "); } + free(copy); } (*params) = num_extensions; break; diff --git a/MG/MG_GL/Implementations/GL/Getter/GL_Getter.h b/MG/MG_GL/Implementations/GL/Getter/GL_Getter.h index 886e2e27..36c40c68 100644 --- a/MG/MG_GL/Implementations/GL/Getter/GL_Getter.h +++ b/MG/MG_GL/Implementations/GL/Getter/GL_Getter.h @@ -8,9 +8,9 @@ #include "../../../../Includes.h" namespace MG_GL::GL { - const ::GLubyte* GetString(GLenum name); - const ::GLubyte* GetStringi(GLenum name, GLuint index); - ::GLenum GetError(); + const GLubyte* GetString(GLenum name); + const GLubyte* GetStringi(GLenum name, GLuint index); + GLenum GetError(); void GetIntegerv(GLenum pname, GLint *params); }