[Fix] (MG_Backend/DirectGLES): correctly bind texture on CopyTexSubImage2D

This commit is contained in:
2025-11-19 10:17:52 +08:00
parent d8cd5a235a
commit caf10a267d
@@ -628,6 +628,22 @@ namespace MobileGL::MG_Backend::DirectGLES {
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
});
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
auto textureObject = bindingSlot.GetBoundObject();
const auto& backendTextureIt = TextureImpl::g_backendTextureObjects.find(textureObject);
SharedPtr<TextureImpl::BackendTextureObject> backendTextureObject;
if (backendTextureIt == TextureImpl::g_backendTextureObjects.end()) {
backendTextureObject = MakeShared<TextureImpl::BackendTextureObject>();
TextureImpl::g_backendTextureObjects[textureObject] = backendTextureObject;
} else {
backendTextureObject = backendTextureIt->second;
}
backendTextureObject->Bind(target);
BindCurrentFBO(FramebufferTarget::Read);
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());