[Fix] (MG_Impl/TextureImpl|FramebufferImpl): Handle texture 0.

This commit is contained in:
BZLZHH
2025-10-31 14:13:38 +08:00
parent 73f8b88b5c
commit 6959405518
2 changed files with 8 additions and 3 deletions
@@ -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,