fix creating window with no icon

This commit is contained in:
faiface 2017-05-01 12:18:23 +02:00
parent 4de5df6980
commit 650263a314
1 changed files with 12 additions and 8 deletions

View File

@ -122,6 +122,17 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
return nil, errors.Wrap(err, "creating window failed")
}
if len(cfg.Icon) > 0 {
imgs := make([]image.Image, len(cfg.Icon))
for i, icon := range cfg.Icon {
pic := pixel.PictureDataFromPicture(icon)
imgs[i] = pic.Image()
}
mainthread.Call(func() {
w.window.SetIcon(imgs)
})
}
w.SetVSync(cfg.VSync)
w.initInput()
@ -131,14 +142,7 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
w.Update()
runtime.SetFinalizer(w, (*Window).Destroy)
imgs := make([]image.Image, len(cfg.Icon))
for i, v := range cfg.Icon {
pic := pixel.PictureDataFromPicture(v)
imgs[i] = pic.Image()
}
mainthread.Call(func() {
w.window.SetIcon(imgs)
})
return w, nil
}