示例#1
0
        protected override bool Load(DX11RenderContext context, string path, out DX11Texture2D result)
        {
            try
            {
                if (Path.GetExtension(path).ToLower() == ".tga")
                {
                    result = null;
                    return(false);
                }
                else
                {
                    ImageLoadInformation info = ImageLoadInformation.FromDefaults();
                    if (this.FInNoMips[0])
                    {
                        info.MipLevels = 1;
                    }
                    result = DX11Texture2D.FromFile(context, path, info);
                }

                #if DEBUG
                result.Resource.DebugName = "FileTexture";
                #endif

                return(true);
            }
            catch
            {
                result = new DX11Texture2D();
                return(false);
            }
        }
示例#2
0
        public DX11FileTexturePoolElement(DX11RenderContext context, string path, bool mips, bool async = false)
        {
            this.FileName = path;
            this.DoMips   = mips;
            this.refcount = 1;


            if (async)
            {
                this.m_task           = new FileTexture2dLoadTask(context, path, mips);
                m_task.StatusChanged += task_StatusChanged;

                context.ResourceScheduler.AddTask(m_task);
            }
            else
            {
                try
                {
                    ImageLoadInformation info = ImageLoadInformation.FromDefaults();
                    if (!this.DoMips)
                    {
                        info.MipLevels = 1;
                    }

                    this.Texture = DX11Texture2D.FromFile(context, path, info);
                    this.Status  = eDX11SheduleTaskStatus.Completed;
                }
                catch
                {
                    this.Status = eDX11SheduleTaskStatus.Error;
                }
            }
        }
示例#3
0
 public GPUDecoder()
 {
     ilf                = ImageLoadInformation.FromDefaults();
     ilf.BindFlags      = BindFlags.ShaderResource;
     ilf.CpuAccessFlags = CpuAccessFlags.None;
     ilf.FirstMipLevel  = 0;
     ilf.MipLevels      = 1;
     ilf.Usage          = ResourceUsage.Default;
 }
 public WICDecoder(MemoryPool mempool)
 {
     mp                 = mempool;
     ilf                = ImageLoadInformation.FromDefaults();
     ilf.BindFlags      = BindFlags.ShaderResource;
     ilf.CpuAccessFlags = CpuAccessFlags.None;
     ilf.FirstMipLevel  = 0;
     ilf.MipLevels      = 1;
     ilf.Usage          = ResourceUsage.Default;
 }
示例#5
0
        protected override void DoProcess()
        {
            ImageLoadInformation info = ImageLoadInformation.FromDefaults();

            if (!this.domips)
            {
                info.MipLevels = 1;
            }

            this.Resource = DX11Texture2D.FromFile(this.Context, path, info);
        }
示例#6
0
            public void SetPosition(DX11RenderContext ctx, int frame)
            {
                int frameindex = frame - this.CurrentFrame;

                frameindex = frameindex < 0 ? 0 : frameindex;
                frameindex = frameindex > Data.FileCount - 1 ? Data.FileCount - 1 : frameindex;

                if (frameindex != CurrentFrame)
                {
                    if (this.Texture == null)
                    {
                        this.Texture.Dispose();
                    }

                    ImageLoadInformation info = ImageLoadInformation.FromDefaults();
                    info.MipLevels = 1;
                    this.Texture   = DX11Texture2D.FromFile(ctx, Data.FilePath[frameindex], info);
                    CurrentFrame   = frameindex;
                }
            }
示例#7
0
 public static DX11Texture2D FromFile(DX11RenderContext context, string path)
 {
     return(DX11Texture2D.FromFile(context, path, ImageLoadInformation.FromDefaults()));
 }
示例#8
0
 public static DX11Texture2D FromMemory(DX11RenderContext context, byte[] data)
 {
     return(FromMemory(context, data, ImageLoadInformation.FromDefaults()));
 }