mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-26 17:55:34 +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"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/loop"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type imageImpl struct {
|
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 {
|
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)")
|
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()
|
i.m.Lock()
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"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 {
|
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 {
|
if p.drawImageHistory == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user