mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app/internal/gl/impl: extract platform dependent opengl bindings
We'd like to support Gio using a different renderer binding than the builtin. A first step is to define the Functions interface in package gl, and extract the concrete implementations to a separate package. Updates #26 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -17,11 +17,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"gioui.org/app/internal/gl"
|
||||
"gioui.org/app/internal/gl/impl"
|
||||
)
|
||||
|
||||
type context struct {
|
||||
owner *window
|
||||
c *gl.Functions
|
||||
c gl.Functions
|
||||
ctx C.CFTypeRef
|
||||
layer C.CFTypeRef
|
||||
init bool
|
||||
@@ -44,12 +45,12 @@ func newContext(w *window) (*context, error) {
|
||||
ctx: ctx,
|
||||
owner: w,
|
||||
layer: C.CFTypeRef(w.contextLayer()),
|
||||
c: new(gl.Functions),
|
||||
c: new(impl.Functions),
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *context) Functions() *gl.Functions {
|
||||
func (c *context) Functions() gl.Functions {
|
||||
return c.c
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
"syscall/js"
|
||||
|
||||
"gioui.org/app/internal/gl"
|
||||
"gioui.org/app/internal/gl/impl"
|
||||
)
|
||||
|
||||
type context struct {
|
||||
ctx js.Value
|
||||
cnv js.Value
|
||||
f *gl.Functions
|
||||
f gl.Functions
|
||||
srgbFBO *gl.SRGBFBO
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ func newContext(w *window) (*context, error) {
|
||||
if ctx.IsNull() {
|
||||
return nil, errors.New("app: webgl is not supported")
|
||||
}
|
||||
f := &gl.Functions{Ctx: ctx}
|
||||
f := &impl.Functions{Ctx: ctx}
|
||||
if err := f.Init(version); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -44,7 +45,7 @@ func newContext(w *window) (*context, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *context) Functions() *gl.Functions {
|
||||
func (c *context) Functions() gl.Functions {
|
||||
return c.f
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package window
|
||||
|
||||
import (
|
||||
"gioui.org/app/internal/gl"
|
||||
"gioui.org/app/internal/gl/impl"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
import "C"
|
||||
|
||||
type context struct {
|
||||
c *gl.Functions
|
||||
c gl.Functions
|
||||
ctx C.CFTypeRef
|
||||
view C.CFTypeRef
|
||||
}
|
||||
@@ -34,13 +35,13 @@ func newContext(w *window) (*context, error) {
|
||||
ctx := C.gio_contextForView(view)
|
||||
c := &context{
|
||||
ctx: ctx,
|
||||
c: new(gl.Functions),
|
||||
c: new(impl.Functions),
|
||||
view: view,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *context) Functions() *gl.Functions {
|
||||
func (c *context) Functions() gl.Functions {
|
||||
return c.c
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ type Callbacks interface {
|
||||
}
|
||||
|
||||
type Context interface {
|
||||
Functions() *gl.Functions
|
||||
Functions() gl.Functions
|
||||
Present() error
|
||||
MakeCurrent() error
|
||||
Release()
|
||||
|
||||
Reference in New Issue
Block a user