app/headless: handle error from Framebuffer.ReadPixels

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-23 09:57:55 +01:00
parent 2df50dda8e
commit 50e98d1e13
+4 -1
View File
@@ -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)