mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphics: Dispose now returns errors
This commit is contained in:
parent
57a9ecd821
commit
2fee1fae22
8
image.go
8
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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user