当前位置: 首页>>代码示例>>C#>>正文


C# RenderTarget.Dispose方法代码示例

本文整理汇总了C#中RenderTarget.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.Dispose方法的具体用法?C# RenderTarget.Dispose怎么用?C# RenderTarget.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderTarget的用法示例。


在下文中一共展示了RenderTarget.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init()
        {
            #region init_gfx
            var form = new RenderForm("MIDITrailer");

            var factory = new FactoryD2D();
            SizeF dpi = factory.DesktopDpi;
            // Create swap chain description
            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = form.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription((int)(GFXResources.Bounds.Width * (dpi.Width / 96f)), (int)(GFXResources.Bounds.Height * (dpi.Height / 96f)), new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard,
            };

            Device device;
            SwapChain swapChain;
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, swapChainDesc, out device, out swapChain);

            Surface backBuffer = Surface.FromSwapChain(swapChain, 0);

            renderTarget = RenderTarget.FromDXGI(factory, backBuffer, new RenderTargetProperties()
            {
                HorizontalDpi = dpi.Width,
                VerticalDpi = dpi.Height,
                MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Default,
                PixelFormat = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Ignore),
                Type = RenderTargetType.Default,
                Usage = RenderTargetUsage.None
            });
            factory.Dispose();

            // Freaking antialiasing lagging up my programs
            renderTarget.AntialiasMode = AntialiasMode.Aliased;

            using (var DXGIFactory = swapChain.GetParent<FactoryDXGI>())
                DXGIFactory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAltEnter);

            form.Size = new Size(Bounds.Width, Bounds.Height);
            form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            #endregion

            GFXResources.Init(renderTarget);

            #region init_timers
            eventTimer = new Timer(15) { Enabled = true };
            eventTimer.Elapsed += delegate
            {
                lock (backlog)
                {
                    while (backlog.Any() && backlog.First().StartTime <= DateTime.Now)
                    {
                        Event ev = backlog.Dequeue();
                        ev.Method();
                    }
                }
            };
            #endregion

            form.KeyDown += (o, e) =>
            {
                Keys key = e.KeyCode;
                switch (key)
                {
                    case Keys.F11:
                        swapChain.IsFullScreen = !swapChain.IsFullScreen;
                        break;
                    case Keys.F:
                        Fancy = !Fancy;
                        UserFancy = !UserFancy;
                        break;
                    case Keys.Up:
                        Delay += 100;
                        notes.Clear();
                        backlog.Clear();
                        break;
                    case Keys.Down:
                        if (Delay >= 100)
                        {
                            Delay -= 100;
                            notes.Clear();
                            backlog.Clear();
                        }
                        break;
                }
            };

            Thread t = new Thread(Load);
            t.Start();

            MessagePump.Run(form, () =>
            {
                UpdateNotePositions();
                UpdateRenderer();
                Paint(renderTarget);
//.........这里部分代码省略.........
开发者ID:HuYang719,项目名称:MIDITrailer,代码行数:101,代码来源:MIDITrailer.cs

示例2: Init

        public void Init()
        {
            #region init_gfx
            Form = new RenderForm("Kazedan");
            var factory = new FactoryD2D();
            SizeF dpi = factory.DesktopDpi;

            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = Form.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription((int)(GFXResources.Bounds.Width * (dpi.Width / 96f)), (int)(GFXResources.Bounds.Height * (dpi.Height / 96f)), new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard,
            };

            Device device;
            SwapChain swapChain;
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, swapChainDesc, out device, out swapChain);

            Surface backBuffer = Surface.FromSwapChain(swapChain, 0);

            renderTarget = RenderTarget.FromDXGI(factory, backBuffer, new RenderTargetProperties()
            {
                HorizontalDpi = dpi.Width,
                VerticalDpi = dpi.Height,
                MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Default,
                PixelFormat = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Ignore),
                Type = RenderTargetType.Default,
                Usage = RenderTargetUsage.None
            });
            factory.Dispose();

            // Freaking antialiasing lagging up my programs
            renderTarget.AntialiasMode = AntialiasMode.Aliased;
            renderTarget.TextAntialiasMode = TextAntialiasMode.Grayscale;
            
            using (var DXGIFactory = swapChain.GetParent<FactoryDXGI>())
                DXGIFactory.SetWindowAssociation(Form.Handle, WindowAssociationFlags.IgnoreAltEnter);

            Form.ClientSize = GFXResources.Bounds;
            Form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            Form.Icon = Properties.Resources.KazedanIcon;
            #endregion

            GFXResources.Init(renderTarget);

            Form.KeyDown += (o, e) =>
            {
                Keys key = e.KeyCode;
                switch (key)
                {
                    case Keys.F11:
                        swapChain.IsFullScreen = !swapChain.IsFullScreen;
                        break;
                    case Keys.F:
                        Sequencer.NoteManager.UserEnabledFancy = !Sequencer.NoteManager.UserEnabledFancy;
                        Sequencer.NoteManager.RenderFancy = Sequencer.NoteManager.UserEnabledFancy;
                        break;
                    case Keys.Up:
                        Sequencer.Delay += 100;
                        Sequencer.Reset();
                        break;
                    case Keys.Down:
                        if (Sequencer.Delay >= 100)
                        {
                            Sequencer.Delay -= 100;
                            Sequencer.Reset();
                        }
                        break;
                    case Keys.Left:
                        if (GFXResources.NoteOffset > 0)
                            GFXResources.NoteOffset--;
                        break;
                    case Keys.Right:
                        if (GFXResources.NoteOffset < 128 - GFXResources.NoteCount)
                            GFXResources.NoteOffset++;
                        break;
                    case Keys.D:
                        Sequencer.ShowDebug = !Sequencer.ShowDebug;
                        break;
                    case Keys.Space:
                        if (Sequencer.Stopped)
                            Sequencer.Start();
                        else
                            Sequencer.Stop();
                        break;
                }
            };

            Thread loadThread = new Thread(Load);
            loadThread.Start();

            Thread controlThread = new Thread(() =>
            {
                loadThread.Join();
                Application.EnableVisualStyles();
//.........这里部分代码省略.........
开发者ID:Netdex,项目名称:Kazedan,代码行数:101,代码来源:Kazedan.cs


注:本文中的RenderTarget.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。