Exemplo n.º 1
0
        public static Icon Load(RenderContext renderContext, IconPathPattern pathPattern)
        {
            ContentManager  content = renderContext.Content;
            ResourceFactory rf      = renderContext.ResourceFactory;
            Texture?        texture = null;
            CommandList     cl      = renderContext.RentCommandList();

            cl.Begin();
            uint layer = 0;

            foreach (string path in pathPattern.EnumeratePaths())
            {
                Texture staging = content.LoadTexture(path, staging: true);
                texture ??= rf.CreateTexture(TextureDescription.Texture2D(
                                                 staging.Width, staging.Height,
                                                 mipLevels: 1, arrayLayers: pathPattern.IconCount,
                                                 staging.Format, TextureUsage.Sampled
                                                 ));
                cl.CopyTexture(
                    staging,
                    srcX: 0, srcY: 0, srcZ: 0,
                    srcMipLevel: 0, srcBaseArrayLayer: 0,
                    texture,
                    dstX: 0, dstY: 0, dstZ: 0,
                    dstMipLevel: 0, layer++,
                    texture.Width, texture.Height,
                    depth: 1, layerCount: 1
                    );
            }
            cl.End();
            renderContext.GraphicsDevice.SubmitCommands(cl);
            renderContext.ReturnCommandList(cl);

            Debug.Assert(texture is not null);
            return(new Icon(texture));
        }
Exemplo n.º 2
0
 public IconPathEnumerable(IconPathPattern pattern)
 {
     _pattern = pattern;
     _i       = 1;
     Current  = string.Empty;
 }