mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Fix] (MG_Impl/GL_Texture): properly unbind texture when texture name == 0
This commit is contained in:
@@ -1292,15 +1292,23 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BindTexture_State(GLenum target, GLuint texture) {
|
void BindTexture_State(GLenum target, GLuint texture) {
|
||||||
// TODO: deal with condition where texture == 0
|
|
||||||
MGLOG_D("BindTexture_State called with target: 0x%X, texture: %u", target, texture);
|
MGLOG_D("BindTexture_State called with target: 0x%X, texture: %u", target, texture);
|
||||||
// ======================= Converting ================================
|
// ======================= Converting ================================
|
||||||
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
||||||
|
|
||||||
// ===================== Error Checking ==============================
|
// ===================== Error Checking ==============================
|
||||||
if (!TextureImpl::ValidateTextureName(texture, true)) return;
|
|
||||||
if (!TextureImpl::ValidateTextureTarget(textureTarget)) return;
|
if (!TextureImpl::ValidateTextureTarget(textureTarget)) return;
|
||||||
|
|
||||||
|
// Name 0 unbinds the current target from the active texture unit.
|
||||||
|
if (texture == 0) {
|
||||||
|
auto& currentUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
|
auto& bindingSlot = currentUnit.GetBindingSlot(textureTarget);
|
||||||
|
bindingSlot.Bind(nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TextureImpl::ValidateTextureName(texture, true)) return;
|
||||||
|
|
||||||
// ======================= Processing ================================
|
// ======================= Processing ================================
|
||||||
Bool doesTextureExist = MG_State::pGLContext->ValidateTextureObject(texture);
|
Bool doesTextureExist = MG_State::pGLContext->ValidateTextureObject(texture);
|
||||||
if (!doesTextureExist) {
|
if (!doesTextureExist) {
|
||||||
|
|||||||
Reference in New Issue
Block a user