mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Return errors when GLContext is missing
This commit is contained in:
parent
121063ee2b
commit
806eb44258
@ -25,7 +25,6 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||
"github.com/hajimehoshi/ebiten/internal/loop"
|
||||
)
|
||||
|
||||
type imageImpl struct {
|
||||
@ -184,7 +183,7 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
||||
}
|
||||
|
||||
func (i *imageImpl) At(x, y int, context *opengl.Context) color.Color {
|
||||
if !loop.IsRunning() {
|
||||
if context == nil {
|
||||
panic("ebiten: At can't be called when the GL context is not initialized (this panic happens as of version 1.4.0-alpha)")
|
||||
}
|
||||
i.m.Lock()
|
||||
|
@ -15,6 +15,7 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
|
||||
@ -91,7 +92,9 @@ func (p *pixels) hasHistoryWith(target *Image) bool {
|
||||
}
|
||||
|
||||
func (p *pixels) resetHistoryIfNeeded(image *graphics.Image, target *Image, context *opengl.Context) error {
|
||||
// TODO: Return error when the main loop is not running yet.
|
||||
if context == nil {
|
||||
return errors.New("ebiten: OpenGL context is missing: before running the main loop, it is forbidden to manipulate images that is used as a drawing source once.")
|
||||
}
|
||||
if p.drawImageHistory == nil {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user