graphics: Clarify when ebiten.Run returns error (#331)

This commit is contained in:
Hajime Hoshi 2017-03-04 02:26:16 +09:00
parent a3e14c9ddb
commit 6b70adf23b
2 changed files with 5 additions and 2 deletions

View File

@ -126,6 +126,7 @@ func (i *imageImpl) At(x, y int, context *opengl.Context) color.Color {
if i.restorable == nil { if i.restorable == nil {
return color.Transparent return color.Transparent
} }
// TODO: Error should be delayed until flushing. Do not panic here.
clr, err := i.restorable.At(x, y, context) clr, err := i.restorable.At(x, y, context)
if err != nil { if err != nil {
panic(err) panic(err)

6
run.go
View File

@ -63,13 +63,15 @@ var theGraphicsContext atomic.Value
// f is a function which is called at every frame. // f is a function which is called at every frame.
// The argument (*Image) is the render target that represents the screen. // The argument (*Image) is the render target that represents the screen.
// //
// This function must be called from the main thread. // Run must be called from the main thread.
// Note that ebiten bounds the main goroutine to the main OS thread by runtime.LockOSThread. // Note that ebiten bounds the main goroutine to the main OS thread by runtime.LockOSThread.
// //
// The given function f is guaranteed to be called 60 times a second // The given function f is guaranteed to be called 60 times a second
// even if a rendering frame is skipped. // even if a rendering frame is skipped.
// f is not called when the screen is not shown. // f is not called when the screen is not shown.
// If f returns error, this function returns the same error. //
// Run returns error when 1) OpenGL error happens, or 2) f returns error.
// In the case of 2), Run returns the same error.
// //
// The size unit is device-independent pixel. // The size unit is device-independent pixel.
func Run(f func(*Image) error, width, height int, scale float64, title string) error { func Run(f func(*Image) error, width, height int, scale float64, title string) error {