From 1b152ae77129b13a39efda802094efd6e4f6219c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 10 Jul 2016 05:04:25 +0900 Subject: [PATCH] opengl: Bug fix: Reset lastTexture when deleting --- internal/graphics/opengl/context_desktop.go | 3 +++ internal/graphics/opengl/context_js.go | 3 +++ internal/graphics/opengl/context_mobile.go | 3 +++ 3 files changed, 9 insertions(+) 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)) }