diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index fbe5f9928..ad0341ada 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -187,6 +187,9 @@ func (c *Context) BindTexture(t Texture) { func (c *Context) DeleteTexture(t Texture) { c.RunOnContextThread(func() error { tt := uint32(t) + if !gl.IsTexture(tt) { + return nil + } gl.DeleteTextures(1, &tt) return nil }) @@ -259,6 +262,9 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error { func (c *Context) DeleteFramebuffer(f Framebuffer) { c.RunOnContextThread(func() error { ff := uint32(f) + if !gl.IsFramebuffer(ff) { + return nil + } // If a framebuffer to be delted is bound, a newly bound framebuffer // will be a default framebuffer. // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 88fdf92b4..d6d7c0a24 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -190,6 +190,9 @@ func (c *Context) BindTexture(t Texture) { func (c *Context) DeleteTexture(t Texture) { gl := c.gl + if !gl.IsTexture(t.Object) { + return + } gl.DeleteTexture(t.Object) } @@ -236,6 +239,9 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error { func (c *Context) DeleteFramebuffer(f Framebuffer) { gl := c.gl + if !gl.IsFramebuffer(f.Object) { + return + } // If a framebuffer to be delted is bound, a newly bound framebuffer // will be a default framebuffer. // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index c73a44122..0ca9bd2a7 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -156,6 +156,9 @@ func (c *Context) BindTexture(t Texture) { func (c *Context) DeleteTexture(t Texture) { gl := c.gl + if !gl.IsTexture(mgl.Texture(t)) { + return + } gl.DeleteTexture(mgl.Texture(t)) } @@ -211,6 +214,9 @@ func (c *Context) FillFramebuffer(r, g, b, a float64) error { func (c *Context) DeleteFramebuffer(f Framebuffer) { gl := c.gl + if !gl.IsFramebuffer(mgl.Framebuffer(f)) { + return + } // If a framebuffer to be delted is bound, a newly bound framebuffer // will be a default framebuffer. // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml