gpu,gpu/backend: implement generic backend.NewDevice

NewDevice creates a Device given an API, which is the necessary GPU
resources for a backend.

Convert gpu.New to take an API instead of a backend.Device directly.

In turn, this frees us to later unexport the backend package along with
the backend implementations (for now just gioui.org/gpu/gl for OpenGL).
It also allows programs that embed Gio (such as gioui.org/example/glfw)
to freely choose a backend, not just OpenGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-04 20:51:47 +01:00
parent 0e723fa192
commit 8ff6546285
19 changed files with 139 additions and 65 deletions
+1 -6
View File
@@ -67,12 +67,7 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
initErr <- err
return
}
b, err := ctx.Backend()
if err != nil {
initErr <- err
return
}
g, err := gpu.New(b)
g, err := gpu.New(ctx.API())
if err != nil {
initErr <- err
return