func (l *TextInstanceList) repackImage() (err error) { var ( newImage *sprites.PackedSheet instance *render.Instance sprite *sprites.Sprite ) if glog.V(1) { glog.Info("Repacking image") } newImage = sprites.NewPackedSheet( l.sheet.Width, l.sheet.Height, ) instance = l.Head() for instance != nil { if err = newImage.Copy(instance.Key, l.sheet); err != nil { return } if sprite, err = newImage.Sheet.Sprite(instance.Key); err != nil { return } instance.Frame = sprite.Index() instance.MarkChanged() instance = instance.Next() } l.sheet = newImage if err = l.generateTexture(); err != nil { return } if glog.V(1) { glog.Info("Done repacking") } return }
func NewTextInstanceList(cfg Config) *TextInstanceList { return &TextInstanceList{ InstanceList: render.NewInstanceList(), cfg: cfg, sheet: sprites.NewPackedSheet( cfg.TextureWidth, cfg.TextureHeight, ), } }