Exemple #1
0
        protected override void OnBeforeInitalizers(object sender, EventArgs e)
        {
            var assets = _resource.GetAssets().Where(asset =>
                                                     asset.Type == AssetType.Texture &&
                                                     asset.NamedIdentifier.Name.StartsWith("block/") &&
                                                     asset.NamedIdentifier.Name.EndsWith(".png"));
            var textureBuilder = new TextureAtlasBuilder();
            var i = 0;

            foreach (var asset in assets)
            {
                using var stream = asset.OpenRead();
                Logger.GetLogger <MainWindow>().Info(asset.NamedIdentifier.FullName);
                var bImg     = new Image(stream);
                var isSingle = bImg.FrameCount == 1;
                var q        = 0;
                foreach (var image in bImg)
                {
                    textureBuilder.Add(isSingle ? asset.NamedIdentifier.FullName : $"{asset.NamedIdentifier.FullName}{{{q}}}", image);
                    i++;
                    q++;
                    if (i == 4096)
                    {
                        break;
                    }
                }

                if (i == 4096)
                {
                    break;
                }
            }

            _atlases = textureBuilder.Build();


            GL.ClearColor(Color4.CornflowerBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.LineWidth(2F);
            base.OnBeforeInitalizers(sender, e);
        }
Exemple #2
0
        protected override void OnContainerInitalized(object sender, EventArgs e)
        {
            var assets = _resource.GetAssets().Where(asset =>
                                                     asset.Type == AssetType.Texture &&
                                                     (asset.NamedIdentifier.Name.StartsWith("block/")
                                                      //|| asset.NamedIdentifier.Name.StartsWith("font/")
                                                     ) && asset.NamedIdentifier.Name.EndsWith(".png"));

            _textureBuilder = new TextureAtlasBuilder();
            var i = 0;

            foreach (var asset in assets)
            {
                using var stream = asset.OpenRead();
                Logger.GetLogger <MainWindow>().Info(asset.NamedIdentifier.FullName);
                var bImg = new Image(stream);
                _textureBuilder.Add(asset.NamedIdentifier.FullName, bImg);
                //var isSingle = bImg.FrameCount == 1;
                //var q = 0;
                //foreach (var image in bImg)
                //{
                //    _textureBuilder.Add(isSingle ? asset.NamedIdentifier.FullName : $"{asset.NamedIdentifier.FullName}{{{q}}}", image);
                //    i++;
                //    q++;
                //    if (i == 4096)
                //        break;
                //}

                if (i == 4096)
                {
                    break;
                }
            }

            base.OnContainerStarted(sender, e);
        }