go mod vendor pins onnxruntime_go v1.12.1, Gio and the rest into v2/vendor so go run/build work without hitting proxy.golang.org (blocked/slow in China). Verified: CGO_ENABLED=1 go build -mod=vendor ./internal/spike and GOOS=windows go build -mod=vendor ./internal/ui both pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
1.0 KiB
Go
60 lines
1.0 KiB
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
//go:build !noopengl
|
|
|
|
package app
|
|
|
|
import (
|
|
"gioui.org/internal/egl"
|
|
)
|
|
|
|
type glContext struct {
|
|
win *window
|
|
*egl.Context
|
|
}
|
|
|
|
func init() {
|
|
drivers = append(drivers, gpuAPI{
|
|
priority: 2,
|
|
initializer: func(w *window) (context, error) {
|
|
disp := egl.NativeDisplayType(w.HDC())
|
|
ctx, err := egl.NewContext(disp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
win, _, _ := w.HWND()
|
|
eglSurf := egl.NativeWindowType(win)
|
|
if err := ctx.CreateSurface(eglSurf); err != nil {
|
|
ctx.Release()
|
|
return nil, err
|
|
}
|
|
if err := ctx.MakeCurrent(); err != nil {
|
|
ctx.Release()
|
|
return nil, err
|
|
}
|
|
defer ctx.ReleaseCurrent()
|
|
ctx.EnableVSync(true)
|
|
return &glContext{win: w, Context: ctx}, nil
|
|
},
|
|
})
|
|
}
|
|
|
|
func (c *glContext) Release() {
|
|
if c.Context != nil {
|
|
c.Context.Release()
|
|
c.Context = nil
|
|
}
|
|
}
|
|
|
|
func (c *glContext) Refresh() error {
|
|
return nil
|
|
}
|
|
|
|
func (c *glContext) Lock() error {
|
|
return c.Context.MakeCurrent()
|
|
}
|
|
|
|
func (c *glContext) Unlock() {
|
|
c.Context.ReleaseCurrent()
|
|
}
|