From 6959405518e083fc81ae9ab7798116ba05f0dc02 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Fri, 31 Oct 2025 14:13:38 +0800 Subject: [PATCH] [Fix] (MG_Impl/TextureImpl|FramebufferImpl): Handle texture 0. --- MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp | 9 +++++++-- MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp index 6932ce46..e547acb9 100644 --- a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp @@ -89,7 +89,7 @@ namespace MobileGL { if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return; if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return; - if (!TextureImpl::ValidateTextureName(texture)) return; + if (!TextureImpl::ValidateTextureName(texture, true)) return; auto& bindingSlot = MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget); auto framebufferObject = bindingSlot.GetBoundObject(); @@ -101,6 +101,11 @@ namespace MobileGL { return; } + if (texture == 0) { + framebufferObject->Detach(attachmentType); + return; + } + auto textureObject = MG_State::pGLContext->GetTextureObject(texture); if (!textureObject) { MG_State::pGLContext->RecordError( @@ -110,7 +115,7 @@ namespace MobileGL { return; } - framebufferObject->AttachTexture(attachmentType, textureObject, level); + framebufferObject->AttachTexture(attachmentType, textureObject, textureObject ? level : 0); } void FramebufferTexture1D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index 6bcbde77..aa1eb363 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -337,7 +337,7 @@ namespace MobileGL { GLboolean IsTexture_State(GLuint texture) { // ======================= Processing ================================ - if (!TextureImpl::ValidateTextureName(texture)) return GL_FALSE; + if (!TextureImpl::ValidateTextureName(texture, true)) return GL_FALSE; return MG_State::pGLContext->ValidateTextureObject(texture) ? GL_TRUE : GL_FALSE; }