graphics: Dispose now returns errors

This commit is contained in:
Hajime Hoshi 2016-05-07 23:34:10 +09:00
parent 57a9ecd821
commit 2fee1fae22
3 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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
}