gpu/gl: remove OpenGL functions parameter from NewBackend

As a consequence, most API is gone from gpu/gl, and embedding Gio in
foreign frameworks don't need to provide an OpenGL implementation.

The next change simplifies the GLFW embedding example accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-12-04 17:56:25 +01:00
parent b8e33bb420
commit ffe5ab51a2
16 changed files with 503 additions and 489 deletions
+2 -8
View File
@@ -3,7 +3,6 @@
package headless
import (
"gioui.org/app/internal/glimpl"
"gioui.org/gpu/backend"
"gioui.org/gpu/gl"
@@ -24,14 +23,13 @@ __attribute__ ((visibility ("hidden"))) void gio_headless_prepareContext(CFTypeR
import "C"
type nsContext struct {
c *glimpl.Functions
ctx C.CFTypeRef
prepared bool
}
func newGLContext() (context, error) {
ctx := C.gio_headless_newContext()
return &nsContext{ctx: ctx, c: new(glimpl.Functions)}, nil
return &nsContext{ctx: ctx}, nil
}
func (c *nsContext) MakeCurrent() error {
@@ -48,11 +46,7 @@ func (c *nsContext) ReleaseCurrent() {
}
func (c *nsContext) Backend() (backend.Device, error) {
return gl.NewBackend(c.c)
}
func (c *nsContext) Functions() *glimpl.Functions {
return c.c
return gl.NewBackend(nil)
}
func (d *nsContext) Release() {
+2 -12
View File
@@ -6,14 +6,13 @@ import (
"errors"
"syscall/js"
"gioui.org/app/internal/glimpl"
"gioui.org/gpu/backend"
"gioui.org/gpu/gl"
"gioui.org/internal/glimpl"
)
type jsContext struct {
ctx js.Value
f *glimpl.Functions
}
func newGLContext() (context, error) {
@@ -26,23 +25,14 @@ func newGLContext() (context, error) {
if ctx.IsNull() {
return nil, errors.New("headless: webgl is not supported")
}
f := &glimpl.Functions{Ctx: ctx}
if err := f.Init(); err != nil {
return nil, err
}
c := &jsContext{
ctx: ctx,
f: f,
}
return c, nil
}
func (c *jsContext) Backend() (backend.Device, error) {
return gl.NewBackend(c.f)
}
func (c *jsContext) Functions() *glimpl.Functions {
return c.f
return gl.NewBackend(glimpl.Context(c.ctx))
}
func (c *jsContext) Release() {