mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
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
-6
@@ -123,12 +123,12 @@ const (
|
||||
storageBindings = 32
|
||||
)
|
||||
|
||||
// NewBackend returns a new Backend.
|
||||
//
|
||||
// Pass a WebGL context if GOOS is "js", otherwise pass nil for the current
|
||||
// context.
|
||||
func NewBackend(ctx Context) (*Backend, error) {
|
||||
f, err := glimpl.NewFunctions(ctx)
|
||||
func init() {
|
||||
backend.NewOpenGLDevice = newOpenGLDevice
|
||||
}
|
||||
|
||||
func newOpenGLDevice(api backend.OpenGL) (backend.Device, error) {
|
||||
f, err := glimpl.NewFunctions(api.Context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user