[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::ValidateFramebufferAttachmentType(attachmentType)) return;
if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) 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& bindingSlot = MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget);
auto framebufferObject = bindingSlot.GetBoundObject(); auto framebufferObject = bindingSlot.GetBoundObject();
@@ -101,6 +101,11 @@ namespace MobileGL {
return; return;
} }
if (texture == 0) {
framebufferObject->Detach(attachmentType);
return;
}
auto textureObject = MG_State::pGLContext->GetTextureObject(texture); auto textureObject = MG_State::pGLContext->GetTextureObject(texture);
if (!textureObject) { if (!textureObject) {
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
@@ -110,7 +115,7 @@ namespace MobileGL {
return; return;
} }
framebufferObject->AttachTexture(attachmentType, textureObject, level); framebufferObject->AttachTexture(attachmentType, textureObject, textureObject ? level : 0);
} }
void FramebufferTexture1D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, void FramebufferTexture1D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
@@ -337,7 +337,7 @@ namespace MobileGL {
GLboolean IsTexture_State(GLuint texture) { GLboolean IsTexture_State(GLuint texture) {
// ======================= Processing ================================ // ======================= 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; return MG_State::pGLContext->ValidateTextureObject(texture) ? GL_TRUE : GL_FALSE;
} }