From 50e98d1e13c011a68e9c4edc7180979d8a668a42 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 23 Feb 2020 09:57:55 +0100 Subject: [PATCH] app/headless: handle error from Framebuffer.ReadPixels Signed-off-by: Elias Naur --- app/headless/headless.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/headless/headless.go b/app/headless/headless.go index f9903e4f..f891e947 100644 --- a/app/headless/headless.go +++ b/app/headless/headless.go @@ -116,12 +116,15 @@ func (w *Window) Frame(frame *op.Ops) { // Screenshot returns an image with the content of the window. func (w *Window) Screenshot() (*image.RGBA, error) { img := image.NewRGBA(image.Rectangle{Max: w.size}) - contextDo(w.ctx, func() error { + err := contextDo(w.ctx, func() error { return w.fbo.ReadPixels( image.Rectangle{ Max: image.Point{X: w.size.X, Y: w.size.Y}, }, img.Pix) }) + if err != nil { + return nil, err + } // Flip image in y-direction. OpenGL's origin is in the lower // left corner. row := make([]uint8, img.Stride)