forked from joejulian/gio
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:
@@ -6,8 +6,7 @@ import (
|
||||
"errors"
|
||||
"syscall/js"
|
||||
|
||||
"gioui.org/gpu/backend"
|
||||
"gioui.org/gpu/gl"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/internal/glimpl"
|
||||
)
|
||||
|
||||
@@ -31,8 +30,8 @@ func newGLContext() (context, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *jsContext) Backend() (backend.Device, error) {
|
||||
return gl.NewBackend(glimpl.Context(c.ctx))
|
||||
func (c *jsContext) API() gpu.API {
|
||||
return gpu.OpenGL{Context: glimpl.Context(c.ctx)}
|
||||
}
|
||||
|
||||
func (c *jsContext) Release() {
|
||||
|
||||
Reference in New Issue
Block a user