diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp index 9f9eac08..c80e6979 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp @@ -34,6 +34,22 @@ namespace MobileGL { return m_mipmaps; } + Bool TextureObjectBase::IsComplete() const { + if (m_internalFormat == TextureInternalFormat::Unknown) { + return false; + } + if (m_mipmaps.empty()) { + return false; + } + for (const auto& level : m_mipmaps) { + if (level.size.x() <= 0 || level.size.y() <= 0 || level.size.z() <= 0) { + return false; + } + } + // TODO: add more completeness checks based on texture type and mipmap levels + return true; + } + MipmapLevelInternal& TextureObjectBase::GetMipmap(Int index) { if (index > m_mipmaps.size()) { // fallback to the last mipmap diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.h b/MobileGL/MG_State/GLState/TextureState/TextureObject.h index 58a79d95..ca515a03 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.h @@ -210,6 +210,7 @@ namespace MobileGL { virtual const Vector& GetMipmaps() const = 0; virtual MipmapLevelInternal& GetMipmap(Int index) = 0; virtual void SetInternalFormat(TextureInternalFormat format) = 0; + virtual Bool IsComplete() const = 0; }; class TextureObjectBase : public ITextureObject { @@ -225,6 +226,7 @@ namespace MobileGL { const Vector& GetMipmaps() const override; MipmapLevelInternal& GetMipmap(Int index) override; void SetInternalFormat(TextureInternalFormat format) override; + Bool IsComplete() const override; protected: virtual void SetMipmapImpl(const MipmapLevelInput& level) = 0;