From 212309083aaa92ec513a71cfd5e609cb7cc9bb4e Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 3 May 2026 19:52:29 +0800 Subject: [PATCH] [Fix] (MG_State/EGLState): fix compilation error on 32-bit arch where EGLAttrib & EGLint are the same type and collides --- MobileGL/MG_State/EGLState/Core.cpp | 37 ++++++++++------------------- MobileGL/MG_State/EGLState/Core.h | 2 -- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/MobileGL/MG_State/EGLState/Core.cpp b/MobileGL/MG_State/EGLState/Core.cpp index 48a7a6a3..f0488b4e 100644 --- a/MobileGL/MG_State/EGLState/Core.cpp +++ b/MobileGL/MG_State/EGLState/Core.cpp @@ -14,6 +14,19 @@ namespace MobileGL { namespace { constexpr EGLint EGL_DISPLAY_MAJOR_VERSION = 1; constexpr EGLint EGL_DISPLAY_MINOR_VERSION = 5; + + template + Optional ParseAttribValue(const AttrType* attribList, EGLint attrib) { + if (!attribList) { + return Nullopt; + } + for (SizeT i = 0; attribList[i] != EGL_NONE; i += 2) { + if (attribList[i] == static_cast(attrib)) { + return attribList[i + 1]; + } + } + return Nullopt; + } } // namespace Bool EGLContext::DisplayLookupKey::operator==(const DisplayLookupKey& rhs) const { @@ -65,30 +78,6 @@ namespace MobileGL { return apiIt->second; } - Optional EGLContext::ParseAttribValue(const EGLint* attribList, EGLint attrib) { - if (!attribList) { - return Nullopt; - } - for (SizeT i = 0; attribList[i] != EGL_NONE; i += 2) { - if (attribList[i] == attrib) { - return attribList[i + 1]; - } - } - return Nullopt; - } - - Optional EGLContext::ParseAttribValue(const EGLAttrib* attribList, EGLint attrib) { - if (!attribList) { - return Nullopt; - } - for (SizeT i = 0; attribList[i] != EGL_NONE; i += 2) { - if (attribList[i] == static_cast(attrib)) { - return attribList[i + 1]; - } - } - return Nullopt; - } - EGLContext::EGLDisplayHandle EGLContext::GetOrCreateDisplay(Uint64 nativeDisplayKey, EGLenum platform) { const DisplayLookupKey key = { .NativeDisplayKey = nativeDisplayKey, diff --git a/MobileGL/MG_State/EGLState/Core.h b/MobileGL/MG_State/EGLState/Core.h index 65a12206..45cb0674 100644 --- a/MobileGL/MG_State/EGLState/Core.h +++ b/MobileGL/MG_State/EGLState/Core.h @@ -210,8 +210,6 @@ namespace MobileGL { } } - static Optional ParseAttribValue(const EGLint* attribList, EGLint attrib); - static Optional ParseAttribValue(const EGLAttrib* attribList, EGLint attrib); static std::thread::id CurrentThreadKey(); EGLDisplayHandle GetOrCreateDisplay(Uint64 nativeDisplayKey, EGLenum platform);