app/headless: bind output framebuffer at render, not creation

Bind the framebuffer as late as possible to lessen the risk of
confusing global state (current framebuffer). Commit
25a19481e3 removed the assumption
that the framebuffer current at gpu.New would always be the output
framebuffer

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-04 13:52:36 +01:00
parent b1dfc94a9b
commit be04dfae83
+1 -1
View File
@@ -62,7 +62,6 @@ func NewWindow(width, height int) (*Window, error) {
fboTex.Release()
return err
}
dev.BindFramebuffer(fbo)
gp, err := gpu.New(dev)
if err != nil {
fbo.Release()
@@ -109,6 +108,7 @@ func (w *Window) Release() {
// operation list.
func (w *Window) Frame(frame *op.Ops) error {
return contextDo(w.ctx, func() error {
w.backend.BindFramebuffer(w.fbo)
w.gpu.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
w.gpu.Collect(w.size, frame)
return w.gpu.Frame()