| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package mtldriver |
| 8 |
|
| 9 |
import ( |
| 10 |
"image" |
| 11 |
|
| 12 |
"github.com/go-gl/glfw/v3.3/glfw" |
| 13 |
"golang.org/x/exp/shiny/screen" |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
type screenImpl struct { |
| 18 |
newWindowCh chan newWindowReq |
| 19 |
} |
| 20 |
|
| 21 |
func (*screenImpl) NewBuffer(size image.Point) (screen.Buffer, error) { |
| 22 |
return &bufferImpl{ |
| 23 |
rgba: image.NewRGBA(image.Rectangle{Max: size}), |
| 24 |
}, nil |
| 25 |
} |
| 26 |
|
| 27 |
func (*screenImpl) NewTexture(size image.Point) (screen.Texture, error) { |
| 28 |
return &textureImpl{ |
| 29 |
rgba: image.NewRGBA(image.Rectangle{Max: size}), |
| 30 |
}, nil |
| 31 |
} |
| 32 |
|
| 33 |
func (s *screenImpl) NewWindow(opts *screen.NewWindowOptions) (screen.Window, error) { |
| 34 |
respCh := make(chan newWindowResp) |
| 35 |
s.newWindowCh <- newWindowReq{ |
| 36 |
opts: opts, |
| 37 |
respCh: respCh, |
| 38 |
} |
| 39 |
glfw.PostEmptyEvent() |
| 40 |
resp := <-respCh |
| 41 |
return resp.w, resp.err |
| 42 |
} |