File tree 4 files changed +29
-36
lines changed
4 files changed +29
-36
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ func (c *wlContext) Refresh() error {
69
69
}
70
70
c .eglWin = eglWin
71
71
eglSurf := egl .NativeWindowType (uintptr (unsafe .Pointer (eglWin )))
72
- if err := c .Context .CreateSurface (eglSurf , width , height ); err != nil {
72
+ if err := c .Context .CreateSurface (eglSurf ); err != nil {
73
73
return err
74
74
}
75
75
if err := c .Context .MakeCurrent (); err != nil {
Original file line number Diff line number Diff line change 5
5
package app
6
6
7
7
import (
8
- "golang.org/x/sys/windows"
9
-
10
8
"gioui.org/internal/egl"
11
9
)
12
10
@@ -24,6 +22,18 @@ func init() {
24
22
if err != nil {
25
23
return nil , err
26
24
}
25
+ win , _ , _ := w .HWND ()
26
+ eglSurf := egl .NativeWindowType (win )
27
+ if err := ctx .CreateSurface (eglSurf ); err != nil {
28
+ ctx .Release ()
29
+ return nil , err
30
+ }
31
+ if err := ctx .MakeCurrent (); err != nil {
32
+ ctx .Release ()
33
+ return nil , err
34
+ }
35
+ defer ctx .ReleaseCurrent ()
36
+ ctx .EnableVSync (true )
27
37
return & glContext {win : w , Context : ctx }, nil
28
38
},
29
39
})
@@ -37,21 +47,6 @@ func (c *glContext) Release() {
37
47
}
38
48
39
49
func (c * glContext ) Refresh () error {
40
- c .Context .ReleaseSurface ()
41
- var (
42
- win windows.Handle
43
- width , height int
44
- )
45
- win , width , height = c .win .HWND ()
46
- eglSurf := egl .NativeWindowType (win )
47
- if err := c .Context .CreateSurface (eglSurf , width , height ); err != nil {
48
- return err
49
- }
50
- if err := c .Context .MakeCurrent (); err != nil {
51
- return err
52
- }
53
- c .Context .EnableVSync (true )
54
- c .Context .ReleaseCurrent ()
55
50
return nil
56
51
}
57
52
Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ func init() {
25
25
if err != nil {
26
26
return nil , err
27
27
}
28
+ win , _ , _ := w .window ()
29
+ eglSurf := egl .NativeWindowType (uintptr (win ))
30
+ if err := ctx .CreateSurface (eglSurf ); err != nil {
31
+ ctx .Release ()
32
+ return nil , err
33
+ }
34
+ if err := ctx .MakeCurrent (); err != nil {
35
+ ctx .Release ()
36
+ return nil , err
37
+ }
38
+ defer ctx .ReleaseCurrent ()
39
+ ctx .EnableVSync (true )
28
40
return & x11Context {win : w , Context : ctx }, nil
29
41
}
30
42
}
@@ -37,17 +49,6 @@ func (c *x11Context) Release() {
37
49
}
38
50
39
51
func (c * x11Context ) Refresh () error {
40
- c .Context .ReleaseSurface ()
41
- win , width , height := c .win .window ()
42
- eglSurf := egl .NativeWindowType (uintptr (win ))
43
- if err := c .Context .CreateSurface (eglSurf , width , height ); err != nil {
44
- return err
45
- }
46
- if err := c .Context .MakeCurrent (); err != nil {
47
- return err
48
- }
49
- defer c .Context .ReleaseCurrent ()
50
- c .Context .EnableVSync (true )
51
52
return nil
52
53
}
53
54
Original file line number Diff line number Diff line change @@ -15,10 +15,9 @@ import (
15
15
)
16
16
17
17
type Context struct {
18
- disp _EGLDisplay
19
- eglCtx * eglContext
20
- eglSurf _EGLSurface
21
- width , height int
18
+ disp _EGLDisplay
19
+ eglCtx * eglContext
20
+ eglSurf _EGLSurface
22
21
}
23
22
24
23
type eglContext struct {
@@ -121,11 +120,9 @@ func (c *Context) VisualID() int {
121
120
return c .eglCtx .visualID
122
121
}
123
122
124
- func (c * Context ) CreateSurface (win NativeWindowType , width , height int ) error {
123
+ func (c * Context ) CreateSurface (win NativeWindowType ) error {
125
124
eglSurf , err := createSurface (c .disp , c .eglCtx , win )
126
125
c .eglSurf = eglSurf
127
- c .width = width
128
- c .height = height
129
126
return err
130
127
}
131
128
You can’t perform that action at this time.
0 commit comments