mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
opengl: Check texture/framebuffer is valid before deleting it
This commit is contained in:
parent
854fa6f32c
commit
5fbbb6dc6a
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user