mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
gpu: expose the rendering implementation
The rendering implementation is needed for using Gio UI with external window libraries such as GLFW. Expose it in the new package gpu. Updates #26 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu"
|
||||||
"gioui.org/app/internal/gpu"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
package headless
|
package headless
|
||||||
|
|
||||||
import "gioui.org/app/internal/gl"
|
import (
|
||||||
import "gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
|
"gioui.org/gpu/gl"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
||||||
@@ -21,7 +23,7 @@ type nsContext struct {
|
|||||||
|
|
||||||
func newContext() (context, error) {
|
func newContext() (context, error) {
|
||||||
ctx := C.gio_headless_newContext()
|
ctx := C.gio_headless_newContext()
|
||||||
return &nsContext{ctx: ctx, c: new(impl.Functions)}, nil
|
return &nsContext{ctx: ctx, c: new(glimpl.Functions)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *nsContext) MakeCurrent() error {
|
func (c *nsContext) MakeCurrent() error {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type jsContext struct {
|
type jsContext struct {
|
||||||
@@ -27,7 +27,7 @@ func newContext() (*jsContext, error) {
|
|||||||
if ctx.IsNull() {
|
if ctx.IsNull() {
|
||||||
return nil, errors.New("headless: webgl is not supported")
|
return nil, errors.New("headless: webgl is not supported")
|
||||||
}
|
}
|
||||||
f := &impl.Functions{Ctx: ctx}
|
f := &glimpl.Functions{Ctx: ctx}
|
||||||
if err := f.Init(version); err != nil {
|
if err := f.Init(version); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/app/internal/glimpl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
@@ -110,7 +110,7 @@ func NewContext(disp NativeDisplayType) (*Context, error) {
|
|||||||
c := &Context{
|
c := &Context{
|
||||||
disp: eglDisp,
|
disp: eglDisp,
|
||||||
eglCtx: eglCtx,
|
eglCtx: eglCtx,
|
||||||
c: new(impl.Functions),
|
c: new(glimpl.Functions),
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
syscall "golang.org/x/sys/windows"
|
syscall "golang.org/x/sys/windows"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -57,7 +57,7 @@ func loadDLLs() error {
|
|||||||
if err := loadDLL(libEGL, "libEGL.dll"); err != nil {
|
if err := loadDLL(libEGL, "libEGL.dll"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := loadDLL(impl.LibGLESv2, "libGLESv2.dll"); err != nil {
|
if err := loadDLL(glimpl.LibGLESv2, "libGLESv2.dll"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// d3dcompiler_47.dll is needed internally for shader compilation to function.
|
// d3dcompiler_47.dll is needed internally for shader compilation to function.
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
// +build darwin linux freebsd openbsd
|
// +build darwin linux freebsd openbsd
|
||||||
|
|
||||||
package impl
|
package glimpl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
package impl
|
package glimpl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Functions struct {
|
type Functions struct {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
package impl
|
package glimpl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -16,8 +16,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
@@ -45,7 +45,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
owner: w,
|
owner: w,
|
||||||
layer: C.CFTypeRef(w.contextLayer()),
|
layer: C.CFTypeRef(w.contextLayer()),
|
||||||
c: new(impl.Functions),
|
c: new(glimpl.Functions),
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
@@ -33,7 +33,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
if ctx.IsNull() {
|
if ctx.IsNull() {
|
||||||
return nil, errors.New("app: webgl is not supported")
|
return nil, errors.New("app: webgl is not supported")
|
||||||
}
|
}
|
||||||
f := &impl.Functions{Ctx: ctx}
|
f := &glimpl.Functions{Ctx: ctx}
|
||||||
if err := f.Init(version); err != nil {
|
if err := f.Init(version); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
package window
|
package window
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/app/internal/gl/impl"
|
"gioui.org/app/internal/glimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -35,7 +35,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
ctx := C.gio_contextForView(view)
|
ctx := C.gio_contextForView(view)
|
||||||
c := &context{
|
c := &context{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
c: new(impl.Functions),
|
c: new(glimpl.Functions),
|
||||||
view: view,
|
view: view,
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/io/event"
|
"gioui.org/io/event"
|
||||||
"gioui.org/io/system"
|
"gioui.org/io/system"
|
||||||
"gioui.org/unit"
|
"gioui.org/unit"
|
||||||
|
|||||||
+1
-1
@@ -6,8 +6,8 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"gioui.org/app/internal/gpu"
|
|
||||||
"gioui.org/app/internal/window"
|
"gioui.org/app/internal/window"
|
||||||
|
"gioui.org/gpu"
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package gpu implements the rendering of Gio drawing operations. It
|
||||||
|
is used by package app and package app/headless and is otherwise not
|
||||||
|
useful except for integrating with external window implementations.
|
||||||
|
*/
|
||||||
package gpu
|
package gpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -12,8 +17,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/internal/opconst"
|
"gioui.org/internal/opconst"
|
||||||
"gioui.org/internal/ops"
|
"gioui.org/internal/ops"
|
||||||
"gioui.org/internal/path"
|
"gioui.org/internal/path"
|
||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
|
"gioui.org/gpu/gl"
|
||||||
"gioui.org/internal/path"
|
"gioui.org/internal/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ package gpu
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gioui.org/app/internal/gl"
|
"gioui.org/gpu/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type timers struct {
|
type timers struct {
|
||||||
Reference in New Issue
Block a user