mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
app,app/headless: expose Backends from window and headless contexts
This is a refactoring change to prepare for another gpu.Backend implementations. Notably, app/loop.go no longer imports gpu/gl. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -26,6 +26,7 @@ type Window struct {
|
||||
|
||||
type context interface {
|
||||
Functions() *glimpl.Functions
|
||||
Backend() (gpu.Backend, error)
|
||||
MakeCurrent() error
|
||||
ReleaseCurrent()
|
||||
Release()
|
||||
@@ -53,7 +54,7 @@ func NewWindow(width, height int) (*Window, error) {
|
||||
ctx.Release()
|
||||
return err
|
||||
}
|
||||
backend, err := gl.NewBackend(f)
|
||||
backend, err := ctx.Backend()
|
||||
if err != nil {
|
||||
fbo.Release()
|
||||
ctx.Release()
|
||||
|
||||
@@ -4,6 +4,8 @@ package headless
|
||||
|
||||
import (
|
||||
"gioui.org/app/internal/glimpl"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/gpu/gl"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -38,6 +40,10 @@ func (c *nsContext) ReleaseCurrent() {
|
||||
C.gio_headless_clearCurrentContext(c.ctx)
|
||||
}
|
||||
|
||||
func (c *nsContext) Backend() (gpu.Backend, error) {
|
||||
return gl.NewBackend(c.c)
|
||||
}
|
||||
|
||||
func (c *nsContext) Functions() *glimpl.Functions {
|
||||
return c.c
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"syscall/js"
|
||||
|
||||
"gioui.org/app/internal/glimpl"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/gpu/gl"
|
||||
)
|
||||
|
||||
type jsContext struct {
|
||||
@@ -37,6 +39,10 @@ func newContext() (*jsContext, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *jsContext) Backend() (gpu.Backend, error) {
|
||||
return gl.NewBackend(c.f)
|
||||
}
|
||||
|
||||
func (c *jsContext) Functions() *glimpl.Functions {
|
||||
return c.f
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user