app/internal/window,app/internal/gl: move gl.Context to package window

Package gl now only defines opengl types and functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-29 19:55:52 +01:00
parent 5fa3dbc70d
commit f25f647a66
11 changed files with 21 additions and 26 deletions
-9
View File
@@ -7,15 +7,6 @@ type (
Enum uint Enum uint
) )
type Context interface {
Functions() *Functions
Present() error
MakeCurrent() error
Release()
Lock()
Unlock()
}
const ( const (
ARRAY_BUFFER = 0x8892 ARRAY_BUFFER = 0x8892
BLEND = 0xbe2 BLEND = 0xbe2
+1 -2
View File
@@ -11,7 +11,6 @@ import (
"unsafe" "unsafe"
"gioui.org/app/internal/egl" "gioui.org/app/internal/egl"
"gioui.org/app/internal/gl"
) )
type context struct { type context struct {
@@ -19,7 +18,7 @@ type context struct {
*egl.Context *egl.Context
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
ctx, err := egl.NewContext(nil) ctx, err := egl.NewContext(nil)
if err != nil { if err != nil {
return nil, err return nil, err
+1 -2
View File
@@ -9,7 +9,6 @@ import (
"unsafe" "unsafe"
"gioui.org/app/internal/egl" "gioui.org/app/internal/egl"
"gioui.org/app/internal/gl"
) )
/* /*
@@ -27,7 +26,7 @@ type context struct {
eglWin *C.struct_wl_egl_window eglWin *C.struct_wl_egl_window
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
disp := egl.NativeDisplayType(unsafe.Pointer(w.display())) disp := egl.NativeDisplayType(unsafe.Pointer(w.display()))
ctx, err := egl.NewContext(disp) ctx, err := egl.NewContext(disp)
if err != nil { if err != nil {
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"unsafe" "unsafe"
"gioui.org/app/internal/egl" "gioui.org/app/internal/egl"
"gioui.org/app/internal/gl"
) )
type context struct { type context struct {
@@ -14,7 +13,7 @@ type context struct {
*egl.Context *egl.Context
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
disp := egl.NativeDisplayType(unsafe.Pointer(w.HDC())) disp := egl.NativeDisplayType(unsafe.Pointer(w.HDC()))
ctx, err := egl.NewContext(disp) ctx, err := egl.NewContext(disp)
if err != nil { if err != nil {
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"unsafe" "unsafe"
"gioui.org/app/internal/egl" "gioui.org/app/internal/egl"
"gioui.org/app/internal/gl"
) )
type x11Context struct { type x11Context struct {
@@ -16,7 +15,7 @@ type x11Context struct {
*egl.Context *egl.Context
} }
func (w *x11Window) NewContext() (gl.Context, error) { func (w *x11Window) NewContext() (Context, error) {
disp := egl.NativeDisplayType(unsafe.Pointer(w.display())) disp := egl.NativeDisplayType(unsafe.Pointer(w.display()))
ctx, err := egl.NewContext(disp) ctx, err := egl.NewContext(disp)
if err != nil { if err != nil {
+1 -1
View File
@@ -121,6 +121,6 @@ func (c *context) MakeCurrent() error {
return nil return nil
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
return newContext(w) return newContext(w)
} }
+1 -1
View File
@@ -90,6 +90,6 @@ func (c *context) MakeCurrent() error {
return nil return nil
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
return newContext(w) return newContext(w)
} }
+1 -1
View File
@@ -71,6 +71,6 @@ func (c *context) MakeCurrent() error {
return nil return nil
} }
func (w *window) NewContext() (gl.Context, error) { func (w *window) NewContext() (Context, error) {
return newContext(w) return newContext(w)
} }
+10 -1
View File
@@ -31,6 +31,15 @@ type Callbacks interface {
Event(e event.Event) Event(e event.Event)
} }
type Context interface {
Functions() *gl.Functions
Present() error
MakeCurrent() error
Release()
Lock()
Unlock()
}
// Driver is the interface for the platform implementation // Driver is the interface for the platform implementation
// of a window. // of a window.
type Driver interface { type Driver interface {
@@ -39,7 +48,7 @@ type Driver interface {
SetAnimating(anim bool) SetAnimating(anim bool)
// ShowTextInput updates the virtual keyboard state. // ShowTextInput updates the virtual keyboard state.
ShowTextInput(show bool) ShowTextInput(show bool)
NewContext() (gl.Context, error) NewContext() (Context, error)
} }
type windowRendezvous struct { type windowRendezvous struct {
+3 -3
View File
@@ -6,8 +6,8 @@ import (
"image" "image"
"runtime" "runtime"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gpu" "gioui.org/app/internal/gpu"
"gioui.org/app/internal/window"
"gioui.org/op" "gioui.org/op"
) )
@@ -36,7 +36,7 @@ type frameResult struct {
err error err error
} }
func newLoop(ctx gl.Context) (*renderLoop, error) { func newLoop(ctx window.Context) (*renderLoop, error) {
l := &renderLoop{ l := &renderLoop{
frames: make(chan frame), frames: make(chan frame),
results: make(chan frameResult), results: make(chan frameResult),
@@ -54,7 +54,7 @@ func newLoop(ctx gl.Context) (*renderLoop, error) {
return l, nil return l, nil
} }
func (l *renderLoop) renderLoop(glctx gl.Context) error { func (l *renderLoop) renderLoop(glctx window.Context) error {
// GL Operations must happen on a single OS thread, so // GL Operations must happen on a single OS thread, so
// pass initialization result through a channel. // pass initialization result through a channel.
initErr := make(chan error) initErr := make(chan error)
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"image" "image"
"time" "time"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/input" "gioui.org/app/internal/input"
"gioui.org/app/internal/window" "gioui.org/app/internal/window"
"gioui.org/io/event" "gioui.org/io/event"
@@ -285,7 +284,7 @@ func (w *Window) run(opts *window.Options) {
w.loop = nil w.loop = nil
} }
} else { } else {
var ctx gl.Context var ctx window.Context
ctx, err = w.driver.NewContext() ctx, err = w.driver.NewContext()
if err == nil { if err == nil {
w.loop, err = newLoop(ctx) w.loop, err = newLoop(ctx)