From 1ee6a1349c63c0ac582910dd7388a5fc53bed869 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Wed, 16 Jul 2025 12:43:05 +0800 Subject: [PATCH] [Fix] (MG_Impl/GL): Correct GL_SHADING_LANGUAGE_VERSION in glGet. --- MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp | 5 +++-- MobileGL/MG_Util/Types.h | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp index 9bf242c5..aa41466d 100644 --- a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp +++ b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp @@ -43,8 +43,9 @@ namespace MobileGL { case GL_SHADING_LANGUAGE_VERSION: static String shadingLanguageVersion; if (shadingLanguageVersion.empty()) { - shadingLanguageVersion = std::format("{} MobileGL", - MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString().c_str()); + shadingLanguageVersion = std::format("{} MobileGL", + MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString( + { true, false }).c_str()); } return (const GLubyte*)shadingLanguageVersion.c_str(); case GL_EXTENSIONS: diff --git a/MobileGL/MG_Util/Types.h b/MobileGL/MG_Util/Types.h index 3bb8e16f..449ec945 100644 --- a/MobileGL/MG_Util/Types.h +++ b/MobileGL/MG_Util/Types.h @@ -2,6 +2,7 @@ namespace MobileGL { using String = std::string; + using StringStream = std::stringstream; using Int8 = int8_t; using Uint8 = uint8_t; using Int16 = int16_t; @@ -17,6 +18,8 @@ namespace MobileGL { using Double = double; template using Vector = std::vector; + template + using Pair = std::pair; template using SharedPtr = std::shared_ptr; template @@ -61,12 +64,11 @@ namespace MobileGL { Int Patch; Optional Suffix; - String toString() const { - String versionStr = std::format("{}.{}.{}", Major, Minor, Patch); - if (Suffix.has_value()) { - versionStr += std::format("{}", Suffix.value()); - } - return versionStr; + String toString(Pair dots = { true, true }, Bool useSuffix = true) const { + StringStream result; + result << Major << (dots.first ? "." : "") << Minor << (dots.second ? "." : "") << Patch << + (useSuffix && Suffix.has_value() ? *Suffix : ""); + return result.str(); } };