From 2fee1fae2224db8842752caf0c831ddac03b5ad6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 7 May 2016 23:34:10 +0900 Subject: [PATCH] graphics: Dispose now returns errors --- image.go | 8 ++++++-- internal/graphics/framebuffer.go | 5 +++-- internal/graphics/texture.go | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/image.go b/image.go index 7d33b519f..c6e31a363 100644 --- a/image.go +++ b/image.go @@ -182,11 +182,15 @@ func (i *Image) Dispose() error { return errors.New("ebiten: image is already disposed") } if i.framebuffer != nil { - i.framebuffer.Dispose(glContext) + if err := i.framebuffer.Dispose(glContext); err != nil { + return err + } i.framebuffer = nil } if i.texture != nil { - i.texture.Dispose(glContext) + if err := i.texture.Dispose(glContext); err != nil { + return err + } i.texture = nil } i.pixels = nil diff --git a/internal/graphics/framebuffer.go b/internal/graphics/framebuffer.go index 5b8f0b755..85521b21c 100644 --- a/internal/graphics/framebuffer.go +++ b/internal/graphics/framebuffer.go @@ -69,12 +69,13 @@ func (f *Framebuffer) Size() (width, height int) { return f.width, f.height } -func (f *Framebuffer) Dispose(c *opengl.Context) { +func (f *Framebuffer) Dispose(c *opengl.Context) error { // Don't delete the default framebuffer. if f.native == opengl.ZeroFramebuffer { - return + return nil } c.DeleteFramebuffer(f.native) + return nil } func (f *Framebuffer) setAsViewport(c *opengl.Context) error { diff --git a/internal/graphics/texture.go b/internal/graphics/texture.go index 3a5417be6..b8eb935be 100644 --- a/internal/graphics/texture.go +++ b/internal/graphics/texture.go @@ -86,6 +86,7 @@ func NewTextureFromImage(c *opengl.Context, img image.Image, filter opengl.Filte return &Texture{native, origSize.X, origSize.Y}, nil } -func (t *Texture) Dispose(c *opengl.Context) { +func (t *Texture) Dispose(c *opengl.Context) error { c.DeleteTexture(t.native) + return nil }