Beispiel #1
0
            public override void CollectFrame(GPUContext context, ref StagingTexture frame, RenderOptions options)
            {
                // Save the staging texture to the file
                var path = options.GetOutputPath(ref frame) + Extension;

                Screenshot.Capture(frame.Texture, path);
            }
        public void Dispose()
        {
            if (ColorConverter.IsValueCreated)
            {
                ColorConverter.Value.Dispose();
            }

            _solidColorBrush?.Dispose();
            _solidColorBrush = null;

            RenderTarget.Dispose();
            RenderTarget = null;

            _factory.Dispose();
            _factory = null;

            _writeFactory?.Dispose();
            _writeFactory = null;

            _imagingFactory?.Dispose();
            _imagingFactory = null;

            PreviewTexture.Dispose();
            PreviewTexture = null;

            DesktopTexture.Dispose();
            DesktopTexture = null;

            StagingTexture.Dispose();
            StagingTexture = null;

            Device.Dispose();
            Device = null;
        }
        public void Dispose()
        {
            _solidColorBrush?.Dispose();
            _solidColorBrush = null;

            RenderTarget.Dispose();
            RenderTarget = null;

            _factory.Dispose();
            _factory = null;

            _writeFactory?.Dispose();
            _writeFactory = null;

            _imagingFactory?.Dispose();
            _imagingFactory = null;

            PreviewTexture.Dispose();
            PreviewTexture = null;

            DesktopTexture.Dispose();
            DesktopTexture = null;

            StagingTexture.Dispose();
            StagingTexture = null;

            Device.Dispose();
            Device = null;
        }
    public MenuView(Device device, MenuModel model)
    {
        this.model = model;

        texture = new Texture2D(device, new Texture2DDescription {
            Width             = PixelSize,
            Height            = PixelSize,
            ArraySize         = 1,
            MipLevels         = 0,
            Format            = Format.B8G8R8A8_UNorm_SRgb,
            SampleDescription = new SampleDescription(1, 0),
            Usage             = ResourceUsage.Default,
            BindFlags         = BindFlags.ShaderResource | BindFlags.RenderTarget,
            OptionFlags       = ResourceOptionFlags.GenerateMipMaps
        });
        textureView = new ShaderResourceView(device, texture);

        for (int i = 0; i < StagingTextureCount; ++i)
        {
            var stagingTexture = StagingTexture.Make(device);
            stagingTextures.Add(stagingTexture);
            readyToMapQueue.Enqueue(stagingTexture);
        }

        author = new MenuViewMessageAuthor();

        model.Changed += () => { wasChangedSinceLastUpdate = true; };

        renderThread = new Thread(MenuRenderProc);
        renderThread.SetApartmentState(ApartmentState.STA);
        renderThread.Start();
    }
Beispiel #5
0
            public string GetOutputPath(ref StagingTexture texture)
            {
                var dir = Path.IsPathRooted(OutputDirectory) ? OutputDirectory : Path.Combine(Globals.ProjectFolder, OutputDirectory);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                var resolution = GetResolution();
                var filename   = Filename;

                filename = filename.Replace("{animation}", Path.GetFileNameWithoutExtension(Animation.Path).Replace(' ', '_'));
                filename = filename.Replace("{fps}", FrameRate.ToString(CultureInfo.InvariantCulture));
                filename = filename.Replace("{frame}", texture.AnimationFrame.ToString());
                filename = filename.Replace("{width}", resolution.X.ToString());
                filename = filename.Replace("{height}", resolution.Y.ToString());
                return(Path.Combine(dir, filename));
            }
 public StagingTexture[] GetRenderTargets()
 {
     D3D.Texture2DDescription renderDesc = engine.D3DDevice.RenderTarget.Texture.Description;
     D3DDevice dev = engine.D3DDevice;
     StagingTexture[] ret;
     if (dev is MultipleOutputDevice)
     {
         MultipleOutputDevice mdev = dev as MultipleOutputDevice;
         ret = new StagingTexture[1 + mdev.NumAdditionalTargets];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = new StagingTexture(dev.Device, renderDesc.Width, renderDesc.Height, renderDesc.Format);
             dev.Device.CopySubresourceRegion(mdev.RenderTextures[i], 0, ret[i].Resource, 0, 0, 0, 0);
         }
         return ret;
     }
     ret = new StagingTexture[1];
     ret[0] = new StagingTexture(dev.Device, renderDesc.Width, renderDesc.Height, renderDesc.Format);
     dev.Device.CopySubresourceRegion(dev.RenderTarget.Texture, 0, ret[0].Resource, 0, 0, 0, 0);
     return ret;
 }
        private static Image ConvertRenderTargetToImage(D3D.Device device, D3D.Texture2D source)
        {
            D3D.Texture2DDescription renderDesc = source.Description;// engine.D3DDevice.RenderTarget.Texture.Description;
            StagingTexture staging = new StagingTexture(device, renderDesc.Width, renderDesc.Height, SlimDX.DXGI.Format.R8G8B8A8_UNorm);

            device.CopySubresourceRegion(source, 0, staging.Resource, 0, 0, 0, 0);

            Image img = CopyTextureToBitmap(staging.Resource as D3D.Texture2D);
            return img;
        }
Beispiel #8
0
 public override void RenderFrame(GPUContext context, ref StagingTexture frame, RenderOptions options, GPUTexture output)
 {
     // Copy texture back to the staging texture
     context.CopyTexture(frame.Texture, 0, 0, 0, 0, output, 0);
 }
Beispiel #9
0
 public abstract void CollectFrame(GPUContext context, ref StagingTexture frame, RenderOptions options);
Beispiel #10
0
 public abstract void RenderFrame(GPUContext context, ref StagingTexture frame, RenderOptions options, GPUTexture output);