diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 692be6741..a3f3a4716 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -225,6 +225,9 @@ func (c *Context) DeleteTexture(t Texture) { if !gl.IsTexture(tt) { return nil } + if c.lastTexture == t { + c.lastTexture = invalidTexture + } gl.DeleteTextures(1, &tt) return nil }) diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 4db846aa2..6bfa78dc2 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -199,6 +199,9 @@ func (c *Context) DeleteTexture(t Texture) { if !gl.IsTexture(t.Object) { return } + if c.lastTexture == t { + c.lastTexture = invalidTexture + } gl.DeleteTexture(t.Object) } diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index c0a905836..691b447ac 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -173,6 +173,9 @@ func (c *Context) DeleteTexture(t Texture) { if !gl.IsTexture(mgl.Texture(t)) { return } + if c.lastTexture == t { + c.lastTexture = invalidTexture + } gl.DeleteTexture(mgl.Texture(t)) }