Пример #1
0
        //this method gets called, when Reinitialize() was called in evaluate,
        //or a graphics device asks for its data
        protected override Texture CreateTexture(int slice, Device device)
        {
            int    p     = unchecked ((int)FHandleIn[slice]);
            IntPtr share = new IntPtr(p);
            Format format;

            if (FFormat[slice].Name == "INTZ")
            {
                format = D3DX.MakeFourCC((byte)'I', (byte)'N', (byte)'T', (byte)'Z');
            }
            else if (FFormat[slice].Name == "RAWZ")
            {
                format = D3DX.MakeFourCC((byte)'R', (byte)'A', (byte)'W', (byte)'Z');
            }
            else if (FFormat[slice].Name == "RESZ")
            {
                format = D3DX.MakeFourCC((byte)'R', (byte)'E', (byte)'S', (byte)'Z');
            }
            else
            {
                format = (Format)Enum.Parse(typeof(Format), FFormat[slice], true);
            }

            Texture texture = null;

            try
            {
                var usage = Usage.Dynamic;
                if (FUsage[slice].Index == (int)(TextureType.RenderTarget))
                {
                    usage = Usage.RenderTarget;
                }
                else if (FUsage[slice].Index == (int)(TextureType.DepthStencil))
                {
                    usage = Usage.DepthStencil;
                }

                texture = new Texture(device, Math.Max(FWidthIn[slice], 1), Math.Max(FHeightIn[slice], 1), 1, usage, format, Pool.Default, ref share);
            }
            catch (Exception e)
            {
                FLogger.Log(LogType.Debug, e.Message + " Handle: " + FHandleIn[slice] + " Format: " + format.ToString());
            }
            return(texture);
        }
Пример #2
0
        public ReadTexture(int width, int height, uint handle, EnumEntry formatEnum, EnumEntry usageEnum)
        {
            Format format;

            if (formatEnum.Name == "INTZ")
            {
                format = D3DX.MakeFourCC((byte)'I', (byte)'N', (byte)'T', (byte)'Z');
            }
            else if (formatEnum.Name == "RAWZ")
            {
                format = D3DX.MakeFourCC((byte)'R', (byte)'A', (byte)'W', (byte)'Z');
            }
            else if (formatEnum.Name == "RESZ")
            {
                format = D3DX.MakeFourCC((byte)'R', (byte)'E', (byte)'S', (byte)'Z');
            }
            else if (formatEnum.Name == "No Specific")
            {
                throw (new Exception("Texture mode not supported"));
            }
            else
            {
                format = (Format)Enum.Parse(typeof(Format), formatEnum, true);
            }

            var usage = Usage.Dynamic;

            if (usageEnum.Index == (int)(TextureType.RenderTarget))
            {
                usage = Usage.RenderTarget;
            }
            else if (usageEnum.Index == (int)(TextureType.DepthStencil))
            {
                usage = Usage.DepthStencil;
            }

            this.FWidth  = width;
            this.FHeight = height;
            this.FHandle = (IntPtr) unchecked ((int)handle);
            this.FFormat = format;
            this.FUsage  = usage;

            Initialise();
        }