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:
@@ -23,7 +23,7 @@ type Window struct {
|
||||
}
|
||||
|
||||
type context interface {
|
||||
Functions() *gl.Functions
|
||||
Functions() gl.Functions
|
||||
MakeCurrent() error
|
||||
ReleaseCurrent()
|
||||
Release()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package headless
|
||||
|
||||
import "gioui.org/app/internal/gl"
|
||||
import "gioui.org/app/internal/gl/impl"
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
||||
@@ -13,14 +14,14 @@ import "gioui.org/app/internal/gl"
|
||||
import "C"
|
||||
|
||||
type nsContext struct {
|
||||
c *gl.Functions
|
||||
c gl.Functions
|
||||
ctx C.CFTypeRef
|
||||
prepared bool
|
||||
}
|
||||
|
||||
func newContext() (context, error) {
|
||||
ctx := C.gio_headless_newContext()
|
||||
return &nsContext{ctx: ctx, c: new(gl.Functions)}, nil
|
||||
return &nsContext{ctx: ctx, c: new(impl.Functions)}, nil
|
||||
}
|
||||
|
||||
func (c *nsContext) MakeCurrent() error {
|
||||
@@ -36,7 +37,7 @@ func (c *nsContext) ReleaseCurrent() {
|
||||
C.gio_headless_clearCurrentContext(c.ctx)
|
||||
}
|
||||
|
||||
func (c *nsContext) Functions() *gl.Functions {
|
||||
func (c *nsContext) Functions() gl.Functions {
|
||||
return c.c
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import (
|
||||
"syscall/js"
|
||||
|
||||
"gioui.org/app/internal/gl"
|
||||
"gioui.org/app/internal/gl/impl"
|
||||
)
|
||||
|
||||
type jsContext struct {
|
||||
ctx js.Value
|
||||
f *gl.Functions
|
||||
f gl.Functions
|
||||
}
|
||||
|
||||
func newContext() (*jsContext, error) {
|
||||
@@ -26,7 +27,7 @@ func newContext() (*jsContext, error) {
|
||||
if ctx.IsNull() {
|
||||
return nil, errors.New("headless: webgl is not supported")
|
||||
}
|
||||
f := &gl.Functions{Ctx: ctx}
|
||||
f := &impl.Functions{Ctx: ctx}
|
||||
if err := f.Init(version); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -37,7 +38,7 @@ func newContext() (*jsContext, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *jsContext) Functions() *gl.Functions {
|
||||
func (c *jsContext) Functions() gl.Functions {
|
||||
return c.f
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user