From 427e069085ba943e03b01e1780af7b5c734b15f3 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Mon, 25 Aug 2025 15:11:56 +0800 Subject: [PATCH] [Feat] (MG_State/TextureState): Implement GetMipmap for TextureObject. --- MobileGL/MG_State/GLState/TextureState/TextureObject.cpp | 8 ++++++++ MobileGL/MG_State/GLState/TextureState/TextureObject.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp index 7da5a935..9f9eac08 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp @@ -34,6 +34,14 @@ namespace MobileGL { return m_mipmaps; } + MipmapLevelInternal& TextureObjectBase::GetMipmap(Int index) { + if (index > m_mipmaps.size()) { + // fallback to the last mipmap + index = static_cast(m_mipmaps.size() - 1); + } + return m_mipmaps[index]; + } + void TextureObjectBase::SetInternalFormat(TextureInternalFormat format) { m_internalFormat = format; } diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.h b/MobileGL/MG_State/GLState/TextureState/TextureObject.h index 0b5a2178..fdbad224 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.h @@ -207,6 +207,7 @@ namespace MobileGL { virtual IntVec3 GetBaseSize() const = 0; virtual SharedPtr GetSamplerObject() const = 0; virtual const Vector& GetMipmaps() const = 0; + virtual MipmapLevelInternal& GetMipmap(Int index) = 0; virtual void SetInternalFormat(TextureInternalFormat format) = 0; }; @@ -221,6 +222,7 @@ namespace MobileGL { IntVec3 GetBaseSize() const override; SharedPtr GetSamplerObject() const override; const Vector& GetMipmaps() const override; + MipmapLevelInternal& GetMipmap(Int index) override; void SetInternalFormat(TextureInternalFormat format) override; protected: