• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SwapChainDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SwapChainDescription的典型用法代码示例。如果您正苦于以下问题:C# SwapChainDescription类的具体用法?C# SwapChainDescription怎么用?C# SwapChainDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SwapChainDescription类属于命名空间,在下文中一共展示了SwapChainDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RenderContainer

        public RenderContainer(SwapChainDescription swapChainDescription, RenderControl control)
        {
            try
            {
                _swapChainDescription = swapChainDescription;

                using (Factory1 factory = new Factory1())
                using (Adapter adapter = factory.GetAdapter(0))
                {
                    Device11 = new Dx11ChainedDevice(adapter, _swapChainDescription);
                    Device10 = new Dx10Device(adapter);
                }

                GraphicsDevice = new GenericGraphicsDevice(Device11.Device);
                SpriteBatch = new SpriteBatch(GraphicsDevice);

                Reset(control.Width, control.Height);

                control.Resize += OnRenderControlResize;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
开发者ID:truongan012,项目名称:Pulse,代码行数:26,代码来源:RenderContainer.cs


示例2: RenderControl

        /// <summary>
        ///     Initializes a new instance of the <see cref="RenderControl" /> class.
        /// </summary>
        public RenderControl()
        {
            SwapChainDescription swapCHainDesc = new SwapChainDescription
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = Handle,
                IsWindowed = true,
                ModeDescription =
                    new ModeDescription(
                        Width,
                        Height,
                        new Rational(60, 1),
                        Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard
            };

            Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.BgraSupport,
                swapCHainDesc,
                out _device,
                out _swapChain);

            Debug.Assert(_swapChain != null, "_swapChain != null");

            // ReSharper disable once AssignNullToNotNullAttribute
            _backBuffer = Surface.FromSwapChain(_swapChain, 0);
            Debug.Assert(_backBuffer != null, "_backBuffer != null");

            Size2F dpi = DirectXResourceManager.FactoryD2D.DesktopDpi;

            RenderTarget renderTarget = new RenderTarget(
                DirectXResourceManager.FactoryD2D,
                _backBuffer,
                new RenderTargetProperties
                {
                    DpiX = dpi.Width,
                    DpiY = dpi.Height,
                    MinLevel = SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT,
                    PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Ignore),
                    Type = RenderTargetType.Default,
                    Usage = RenderTargetUsage.None
                });
            _renderTargetContainer = RenderTargetContainer.CreateContainer(renderTarget, out _renderTargetRef);

            using (FactoryDXGI factory = _swapChain.GetParent<FactoryDXGI>())
            {
                Debug.Assert(factory != null, "factory != null");
                factory.MakeWindowAssociation(Handle, WindowAssociationFlags.IgnoreAltEnter);
            }

            _renderThread = new Thread(RenderLoop)
            {
                Name = "Render Thread",
                IsBackground = true
            };
        }
开发者ID:billings7,项目名称:EscherTilier,代码行数:63,代码来源:RenderControl.cs


示例3: InitializeD3D

        public void InitializeD3D()
        {
            var description = new SwapChainDescription()
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = form.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard
            };

            //Create swap chain
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, description, out this.device, out swapChain);
            // create a view of our render target, which is the backbuffer of the swap chain we just created
            // setting a viewport is required if you want to actually see anything
            var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0);
            renderTarget = new RenderTargetView(device, resource);
            var context = device.ImmediateContext;
            var viewport = new Viewport(0.0f, 0.0f, form.ClientSize.Width, form.ClientSize.Height);
            context.OutputMerger.SetTargets(renderTarget);
            context.Rasterizer.SetViewports(viewport);
        }
开发者ID:jpchiodini,项目名称:Gesture-Recognition-Interface,代码行数:25,代码来源:Start_Screen.cs


示例4: InitializeDeviceResources

		private void InitializeDeviceResources()
		{
			ModeDescription backBufferDesc = new ModeDescription(Width, Height, new Rational(60, 1), Format.R8G8B8A8_UNorm);
			
			// Descriptor for the swap chain
			SwapChainDescription swapChainDesc = new SwapChainDescription()
			{
				ModeDescription = backBufferDesc,
				SampleDescription = new SampleDescription(1, 0),
				Usage = Usage.RenderTargetOutput,
				BufferCount = 1,
				OutputHandle = renderForm.Handle,
				IsWindowed = true
			};

			// Create device and swap chain
			D3D11.Device.CreateWithSwapChain(DriverType.Hardware, D3D11.DeviceCreationFlags.None, swapChainDesc, out d3dDevice, out swapChain);
			d3dDeviceContext = d3dDevice.ImmediateContext;

			// Create render target view for back buffer
			using(D3D11.Texture2D backBuffer = swapChain.GetBackBuffer<D3D11.Texture2D>(0))
			{
				renderTargetView = new D3D11.RenderTargetView(d3dDevice, backBuffer);
			}

			// Set back buffer as current render target view
			d3dDeviceContext.OutputMerger.SetRenderTargets(renderTargetView);
		}
开发者ID:Mofangbao,项目名称:SharpDXTutorials,代码行数:28,代码来源:Game.cs


示例5: CreateImpl

        protected override void CreateImpl()
        {
            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount = (int)Desc.BufferCount,
                ModeDescription = new ModeDescription((int) Desc.Width, (int)Desc.Height, new Rational(0,0), Memory.Enums.ToDXGIFormat[(int)Desc.Format]),
                Usage = Usage.RenderTargetOutput,
                SwapEffect = SwapEffect.FlipDiscard,
                OutputHandle = Desc.WindowHandle,
                SampleDescription = new SampleDescription
                {
                    Count = (int) Desc.SampleCount,
                    Quality = (int) Desc.SampleQuality
                },
                IsWindowed = !Desc.Fullscreen
            };
            using (var factory = new Factory4())
            {
                var tempSwapChain = new SharpDX.DXGI.SwapChain(factory, ((CommandQueue)Desc.AssociatedGraphicsQueue).CommandQueueD3D12, swapChainDesc);
                SwapChainDXGI = tempSwapChain.QueryInterface<SwapChain3>();
                tempSwapChain.Dispose();
                CurrentBackBufferIndex = (uint)SwapChainDXGI.CurrentBackBufferIndex;
            }

            SwapChainDXGI.DebugName = Label;

            Log.Info("Created SwapChain");
        }
开发者ID:Wumpf,项目名称:ClearSight,代码行数:28,代码来源:SwapChain.cs


示例6: CreateDeviceSwapChainAndRenderTarget

        public static void CreateDeviceSwapChainAndRenderTarget(Form form,
            out Device device, out SwapChain swapChain, out RenderTargetView renderTarget)
        {
            try
            {
                // the debug mode requires the sdk to be installed otherwise an exception is thrown
                device = new Device(DeviceCreationFlags.Debug);
            }
            catch (Direct3D10Exception)
            {
                device = new Device(DeviceCreationFlags.None);
            }

            var swapChainDescription = new SwapChainDescription();
            var modeDescription = new ModeDescription();
            var sampleDescription = new SampleDescription();

            modeDescription.Format = Format.R8G8B8A8_UNorm;
            modeDescription.RefreshRate = new Rational(60, 1);
            modeDescription.Scaling = DisplayModeScaling.Unspecified;
            modeDescription.ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified;

            modeDescription.Width = WIDTH;
            modeDescription.Height = HEIGHT;

            sampleDescription.Count = 1;
            sampleDescription.Quality = 0;

            swapChainDescription.ModeDescription = modeDescription;
            swapChainDescription.SampleDescription = sampleDescription;
            swapChainDescription.BufferCount = 1;
            swapChainDescription.Flags = SwapChainFlags.None;
            swapChainDescription.IsWindowed = true;
            swapChainDescription.OutputHandle = form.Handle;
            swapChainDescription.SwapEffect = SwapEffect.Discard;
            swapChainDescription.Usage = Usage.RenderTargetOutput;

            using (var factory = new Factory())
            {
                swapChain = new SwapChain(factory, device, swapChainDescription);
            }

            using (var resource = swapChain.GetBuffer<Texture2D>(0))
            {
                renderTarget = new RenderTargetView(device, resource);
            }

            var viewport = new Viewport
            {
                X = 0,
                Y = 0,
                Width = WIDTH,
                Height = HEIGHT,
                MinZ = 0.0f,
                MaxZ = 1.0f
            };

            device.Rasterizer.SetViewports(viewport);
            device.OutputMerger.SetTargets(renderTarget);
        }
开发者ID:Christof,项目名称:afterglow,代码行数:60,代码来源:EmptyWindow.cs


示例7: InitalizeGraphics

		private void InitalizeGraphics()
		{
			if (Window.RenderCanvasHandle == IntPtr.Zero)
				throw new InvalidOperationException("Window handle cannot be zero");

			SwapChainDescription swapChainDesc = new SwapChainDescription()
			{
				BufferCount = 1,
				Flags = SwapChainFlags.None,
				IsWindowed = true,
				OutputHandle = Window.RenderCanvasHandle,
				SwapEffect = SwapEffect.Discard,
				Usage = Usage.RenderTargetOutput,
				ModeDescription = new ModeDescription()
				{
					Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
					//Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm,
					Width = Window.ClientSize.Width,
					Height = Window.ClientSize.Height,
					RefreshRate = new Rational(60, 1),
					Scaling = DisplayModeScaling.Unspecified,
					ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified
				},
				SampleDescription = new SampleDescription(1, 0)
			};

			var giFactory = new SlimDX.DXGI.Factory();
			var adapter = giFactory.GetAdapter(0);

			Device device;
			SwapChain swapChain;
			Device.CreateWithSwapChain(adapter, DriverType.Hardware, DeviceCreationFlags.None, swapChainDesc, out device, out swapChain);
			_swapChain = swapChain;
			GraphicsDevice = device;

			// create a view of our render target, which is the backbuffer of the swap chain we just created
			using (var resource = SlimDX.Direct3D10.Resource.FromSwapChain<Texture2D>(swapChain, 0))
			{
				_backBuffer = new RenderTargetView(device, resource);
			}

			// setting a viewport is required if you want to actually see anything
			var viewport = new Viewport(0, 0, Window.ClientSize.Width, Window.ClientSize.Height);
			device.OutputMerger.SetTargets(_backBuffer);
			device.Rasterizer.SetViewports(viewport);

			CreateDepthStencil();
			LoadVisualizationEffect();

			// Allocate a large buffer to write the PhysX visualization vertices into
			// There's more optimized ways of doing this, but for this sample a large buffer will do
			_userPrimitivesBuffer = new SlimDX.Direct3D10.Buffer(GraphicsDevice, VertexPositionColor.SizeInBytes * 50000, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None);

			var elements = new[]
			{
				new InputElement("Position", 0, Format.R32G32B32A32_Float, 0, 0),
				new InputElement("Color", 0, Format.R32G32B32A32_Float, 16, 0)
			};
			_inputLayout = new InputLayout(GraphicsDevice, _visualizationEffect.RenderScenePass0.Description.Signature, elements);
		}
开发者ID:dkushner,项目名称:PhysX.NET,代码行数:60,代码来源:Engine.cs


示例8: Renderer

 public Renderer(int Width, int Height, IntPtr? OutputHandle)
 {
     if (Width < 1)
         Width = 1;
     if (Height < 1)
         Height = 1;
     bufferWidth = Width;
     bufferHeight = Height;
     deviceUsers++;
     if (device == null)
         device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_11_0);
     if (OutputHandle.HasValue)
     {
         SwapChainDescription swapChainDesc = new SwapChainDescription()
         {
             BufferCount = 1,
             ModeDescription = new ModeDescription(BufferWidth, BufferHeight, new Rational(120, 1), Format.R8G8B8A8_UNorm),
             IsWindowed = true,
             OutputHandle = OutputHandle.Value,
             SampleDescription = BufferSampleDescription,
             SwapEffect = SwapEffect.Discard,
             Usage = Usage.RenderTargetOutput,
             Flags = SwapChainFlags.AllowModeSwitch,
         };
         swapChain = new SwapChain(device.Factory, Device, swapChainDesc);
         using (var factory = swapChain.GetParent<Factory>())
             factory.SetWindowAssociation(OutputHandle.Value, WindowAssociationFlags.IgnoreAltEnter);
     }
     LightingSystem = new ForwardLighting(this);
     SetupRenderTargets();
     LightingSystem.Initialize();
 }
开发者ID:RomanHodulak,项目名称:DeferredLightingD3D11,代码行数:32,代码来源:Renderer.cs


示例9: DX11SwapChain

        public DX11SwapChain(DX11RenderContext context, IntPtr handle, Format format, SampleDescription sampledesc)
        {
            this.context = context;
            this.handle = handle;

            SwapChainDescription sd = new SwapChainDescription()
            {
                BufferCount = 1,
                ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), format),
                IsWindowed = true,
                OutputHandle = handle,
                SampleDescription = sampledesc,
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput | Usage.ShaderInput,
                Flags = SwapChainFlags.None
            };

            if (sd.SampleDescription.Count == 1 && context.IsFeatureLevel11)
            {
                sd.Usage |= Usage.UnorderedAccess;
                this.allowuav = true;
            }

            this.swapchain = new SwapChain(context.Device.Factory, context.Device, sd);

            this.Resource = Texture2D.FromSwapChain<Texture2D>(this.swapchain, 0);

            this.context.Factory.SetWindowAssociation(handle, WindowAssociationFlags.IgnoreAltEnter);

            this.RTV = new RenderTargetView(context.Device, this.Resource);
            this.SRV = new ShaderResourceView(context.Device, this.Resource);
            if (this.allowuav) { this.UAV = new UnorderedAccessView(context.Device, this.Resource); }

            this.desc = this.Resource.Description;
        }
开发者ID:kopffarben,项目名称:FeralTic,代码行数:35,代码来源:DX11SwapChain.cs


示例10: Initialize

        protected override void Initialize(DemoConfiguration demoConfiguration)
        {
            // SwapChain description
            var desc = new SwapChainDescription()
            {
                BufferCount = 1,
                ModeDescription = 
                    new ModeDescription(demoConfiguration.Width, demoConfiguration.Height,
                                        new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed = true,
                OutputHandle = DisplayHandle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            // Create Device and SwapChain
            Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, new [] { FeatureLevel.Level_10_0 }, desc, out _device, out _swapChain);

            // Ignore all windows events
            Factory factory = _swapChain.GetParent<Factory>();
            factory.MakeWindowAssociation(DisplayHandle, WindowAssociationFlags.IgnoreAll);

            // New RenderTargetView from the backbuffer
            _backBuffer = Texture2D.FromSwapChain<Texture2D>(_swapChain, 0);

            _backBufferView = new RenderTargetView(_device, _backBuffer);
        }
开发者ID:MaybeMars,项目名称:SharpDX-Samples,代码行数:28,代码来源:Direct3D11DemoApp.cs


示例11: DX11Renderer

        public DX11Renderer(IntPtr windowHandle, Size2 size, Device dev = null)
        {
            RenderSize = size;
            _windowHandle = windowHandle;
            if(dev != null)
            {
                _dxDevice = dev;
            }
            else
            {
                var swapchainDesc = new SwapChainDescription()
                {
                    BufferCount = 2,
                    ModeDescription =
                        new ModeDescription(size.Width, size.Height,
                                            new Rational(60, 1), Format.R8G8B8A8_UNorm),
                    IsWindowed = true,
                    OutputHandle = windowHandle,
                    SampleDescription = new SampleDescription(1, 0),
                    SwapEffect = SwapEffect.Discard,
                    Usage = Usage.RenderTargetOutput
                };

                // Create Device and SwapChain
                Device.CreateWithSwapChain(DriverType.Hardware,
                   DeviceCreationFlags.None, swapchainDesc, out _dxDevice, out _swapChain);

                // Ignore all windows events
                //    var factory = _swapChain.GetParent<Factory>();
                //    factory.MakeWindowAssociation(windowHandle, WindowAssociationFlags.None);

                Reset(size.Width, size.Height);
            }
        }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:34,代码来源:DX11Renderer.cs


示例12: DX11GraphicsDevice

        public DX11GraphicsDevice(Form form)
        {
            this.Form = form;

            var scDesc = new SwapChainDescription
            {
                BufferCount = 2,
                Flags = SwapChainFlags.AllowModeSwitch,
                IsWindowed = true,
                ModeDescription = new ModeDescription(
                        form.ClientSize.Width,
                        form.ClientSize.Height,
                        new Rational(60, 1),
                        format),
                OutputHandle = form.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Sequential,
                Usage = Usage.RenderTargetOutput
            };

            var levels = new[] { FeatureLevel.Level_9_2, FeatureLevel.Level_9_1 };

            Device.CreateWithSwapChain(
                    DriverType.Hardware,
                    DeviceCreationFlags.None,
                    levels,
                    scDesc,
                    out device,
                    out swapChain);

            ResetDevice();

            form.ResizeEnd += ResizeEnd;
        }
开发者ID:Bananattack,项目名称:ankh,代码行数:34,代码来源:DX11GraphicsDevice.cs


示例13: Initialize

        public override void Initialize()
        {
            Device tmpDevice;
            SwapChain sc;
            using (var rf = new RenderForm())
            {
                var desc = new SwapChainDescription
                {
                    BufferCount = 1,
                    Flags = SwapChainFlags.None,
                    IsWindowed = true,
                    ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
                    OutputHandle = rf.Handle,
                    SampleDescription = new SampleDescription(1, 0),
                    SwapEffect = SwapEffect.Discard,
                    Usage = Usage.RenderTargetOutput
                };

                var res = Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out tmpDevice, out sc);
                if (res.IsSuccess)
                {
                    using (tmpDevice)
                    {
                        using (sc)
                        {
                            PresentPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_PRESENT);
                            ResetTargetPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_RESIZETARGET);
                        }
                    }
                }
            }

            _presentDelegate = Pulse.Magic.RegisterDelegate<Direct3D11Present>(PresentPointer);
            _presentHook = Pulse.Magic.Detours.CreateAndApply(_presentDelegate, new Direct3D11Present(Callback), "D11Present");
        }
开发者ID:Grafalck,项目名称:Questor,代码行数:35,代码来源:D3D11.cs


示例14: Initialize

        public override void Initialize()
        {
            using (var fac = new Factory())
            {
                using (var tmpDevice = new Device(fac.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.None))
                {
                    using (var rf = new RenderForm())
                    {
                        var desc = new SwapChainDescription
                        {
                            BufferCount = 1,
                            Flags = SwapChainFlags.None,
                            IsWindowed = true,
                            ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                            OutputHandle = rf.Handle,
                            SampleDescription = new SampleDescription(1, 0),
                            SwapEffect = SwapEffect.Discard,
                            Usage = Usage.RenderTargetOutput
                        };
                        using (var sc = new SwapChain(fac, tmpDevice, desc))
                        {
                            PresentPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_PRESENT);
                            ResetTargetPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_RESIZETARGET);
                        }
                    }
                }
            }

            _presentDelegate = Pulse.Magic.RegisterDelegate<Direct3D10Present>(PresentPointer);
            _presentHook = Pulse.Magic.Detours.CreateAndApply(_presentDelegate, new Direct3D10Present(Callback), "D10Present");
        }
开发者ID:miceiken,项目名称:D3DDetour,代码行数:31,代码来源:D3D10.cs


示例15: D3D11RenderingPane

        public D3D11RenderingPane( Factory dxgiFactory, SlimDX.Direct3D11.Device d3D11Device, DeviceContext d3D11DeviceContext, D3D11HwndDescription d3D11HwndDescription )
        {
            mDxgiFactory = dxgiFactory;
            mD3D11Device = d3D11Device;
            mD3D11DeviceContext = d3D11DeviceContext;

            var swapChainDescription = new SwapChainDescription
                                       {
                                           BufferCount = 1,
                                           ModeDescription =
                                               new ModeDescription( d3D11HwndDescription.Width,
                                                                    d3D11HwndDescription.Height,
                                                                    new Rational( 60, 1 ),
                                                                    Format.R8G8B8A8_UNorm ),
                                           IsWindowed = true,
                                           OutputHandle = d3D11HwndDescription.Handle,
                                           SampleDescription = new SampleDescription( 1, 0 ),
                                           SwapEffect = SwapEffect.Discard,
                                           Usage = Usage.RenderTargetOutput
                                       };

            mSwapChain = new SwapChain( mDxgiFactory, mD3D11Device, swapChainDescription );
            mDxgiFactory.SetWindowAssociation( d3D11HwndDescription.Handle, WindowAssociationFlags.IgnoreAll );

            CreateD3D11Resources( d3D11HwndDescription.Width, d3D11HwndDescription.Height );

            PauseRendering = false;
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:28,代码来源:D3D11RenderingPane.cs


示例16: LoadPipeline

        private void LoadPipeline(IntPtr handleToWindow)
        {
            // create swap chain descriptor
            var swapChainDescription = new SwapChainDescription()
            {
                BufferCount = SwapBufferCount,
                ModeDescription = new ModeDescription(Format.R8G8B8A8_UNorm),
                Usage = Usage.RenderTargetOutput,
                OutputHandle = handleToWindow,
                SwapEffect = SwapEffect.FlipDiscard,
                SampleDescription = new SampleDescription(1, 0),
                IsWindowed = true
            };

            // create the device
            try
            {
                device = CreateDeviceWithSwapChain(DriverType.Hardware, FeatureLevel.Level_11_0, swapChainDescription, out swapChain, out commandQueue);
            }
            catch (SharpDXException)
            {
                device = CreateDeviceWithSwapChain(DriverType.Warp, FeatureLevel.Level_11_0, swapChainDescription, out swapChain, out commandQueue);
            }

            // create command queue and allocator objects
            commandListAllocator = device.CreateCommandAllocator(CommandListType.Direct);
        }
开发者ID:liquidboy,项目名称:X,代码行数:27,代码来源:D3D12Pipeline.cs


示例17: OnLoad

 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     SwapChainDescription desc=new SwapChainDescription()
     {
         BufferCount = 2,
         Flags = SwapChainFlags.AllowModeSwitch,
         IsWindowed = true,
         ModeDescription = new ModeDescription()
         {
             Format = Format.R8G8B8A8_UNorm,
             Height = Height,
             Width = Width,
             RefreshRate = new Rational(1,60),
             Scaling = DisplayModeScaling.Centered,
             ScanlineOrdering = DisplayModeScanlineOrdering.Progressive
         },
         OutputHandle = Handle,
         SampleDescription = new SampleDescription(1,0),
         SwapEffect = SwapEffect.Discard,
         Usage = Usage.RenderTargetOutput
     };
     Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None,
         new FeatureLevel[1] {FeatureLevel.Level_11_0}, desc, out device, out swapChain);
     using (Texture2D tex=Texture2D.FromSwapChain<Texture2D>(swapChain,0))
     {
         renderTarget=new RenderTargetView(device,tex);
     }
 }
开发者ID:kyasbal-1994,项目名称:DXPractice1,代码行数:29,代码来源:Form1.cs


示例18: D3DManager

        public D3DManager(Form renderForm)
        {
            if (renderForm == null) throw new ArgumentNullException("renderForm");

            var swapChainDescription = new SwapChainDescription {
                BufferCount = 1,
                IsWindowed = true,
                ModeDescription = new ModeDescription(renderForm.ClientSize.Width, renderForm.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                OutputHandle = renderForm.Handle,
                SampleDescription = new SampleDescription(4, 4),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, swapChainDescription, out Device, out SwapChain);

            SwapChain.GetParent<Factory>().SetWindowAssociation(renderForm.Handle, WindowAssociationFlags.IgnoreAll);

            CreateRenderTargets(renderForm.ClientSize.Width, renderForm.ClientSize.Height);

            Device.ImmediateContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);

            Device.ImmediateContext.Rasterizer.State = RasterizerState.FromDescription(Device,
                new RasterizerStateDescription {
                    CullMode = CullMode.Back,
                    FillMode = FillMode.Solid,
                    IsMultisampleEnabled = true
                });
        }
开发者ID:carlt,项目名称:SubdivisionRenderer,代码行数:29,代码来源:D3DManager.cs


示例19: Direct3D11Base

        public Direct3D11Base(Form form,
            SwapChainDescription swapDesc,
            Adapter adapter = null,
            DriverType type = DriverType.Hardware,
            DeviceCreationFlags flags = DeviceCreationFlags.None,
            FeatureLevel[] levels = null)
        {
            IsDisposed = false;

            try
            {
                _isInitializing = true;

                _form = form;

                _isComposited = DwmApi.IsCompositionEnabled;
                if (_isComposited)
                {
                    DwmApi.EnableMMCSS(true);
                    DwmPresentParameters present = new DwmPresentParameters()
                    {
                        IsQueued = true,
                        BufferCount = 2,
                        RefreshesPerFrame = 1,
                    };
                    DwmApi.SetPresentParameters(form.Handle, ref present);
                }

                if (swapDesc.OutputHandle != IntPtr.Zero) { throw new ArgumentException("Output handle must not be set."); }
                if (swapDesc.Usage != Usage.RenderTargetOutput) { throw new ArgumentException("Usage must be RenderTargetOutput."); }

                swapDesc.OutputHandle = _form.Handle;
                bool setFullscreen = !swapDesc.IsWindowed;
                swapDesc.IsWindowed = true;

                Device.CreateWithSwapChain(adapter, type, DeviceCreationFlags.None, levels, swapDesc, out _device, out _swapChain);
                _swapChain.ResizeTarget(swapDesc.ModeDescription);
                _factory = _swapChain.GetParent<Factory>();
                _factory.SetWindowAssociation(_form.Handle, WindowAssociationFlags.IgnoreAll);

                _form.SizeChanged += SizeChanged_Handler;
                _form.ResizeBegin += ResizeBegin_Handler;
                _form.Resize += Resize_Handler;
                _form.ResizeEnd += ResizeEnd_Handler;
                _form.KeyDown += KeyDown_Handler;

                if (setFullscreen)
                {
                    ChangeMode(true);
                }

                _isInitializing = false;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
开发者ID:MiLO83,项目名称:libsnesdotnet,代码行数:59,代码来源:Direct3D11Base.cs


示例20: GenericDisplay

		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public GenericDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			try {
				window = CreateTouchForm(parameters, null);
			}
			catch (System.EntryPointNotFoundException e) {
				Log.Warning("Looks like your system does't support touch gestures. You need Windows 8.1 or newer for this.");
				window = CreateForm(parameters, null);
			}

			try {
				NvApi.Initialize();
				NvApi.Stereo_Disable();
			}
			catch (NVException nvex) {
				Log.Debug(nvex.Message);
			}

			var deviceFlags			=	DeviceCreationFlags.BgraSupport;
				//deviceFlags			|=	DeviceCreationFlags.SingleThreaded;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

			var driverType			=	DriverType.Hardware;

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 


			swapChainDesc = new SwapChainDescription () {
				BufferCount			=	1,	// UE4 use this.
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};

			D3D.Device.CreateWithSwapChain( driverType, deviceFlags, new[]{ featureLevel }, swapChainDesc, out d3dDevice, out swapChain );

			//Log.Message("   compute shaders : {0}", d3dDevice.CheckFeatureSupport(Feature.ComputeShaders) );
			//Log.Message("   shader doubles  : {0}", d3dDevice.CheckFeatureSupport(Feature.ShaderDoubles) );
			//Log.Message("   threading       : {0}", d3dDevice.CheckFeatureSupport(Feature.Threading) );
			bool driverConcurrentCreates;
			bool driverCommandLists;
			d3dDevice.CheckThreadingSupport( out driverConcurrentCreates, out driverCommandLists );
			//d3dDevice.GetCounterCapabilities();
			Log.Message("   Concurrent Creates : {0}", driverConcurrentCreates );
			Log.Message("   Command Lists      : {0}", driverCommandLists );


			var factory		=	swapChain.GetParent<Factory>();
			factory.MakeWindowAssociation( window.Handle, WindowAssociationFlags.IgnoreAll );


			clientWidth		=	window.ClientSize.Width;
			clientHeight	=	window.ClientSize.Height;
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:62,代码来源:GenericDisplay.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SwissEph类代码示例发布时间:2022-05-24
下一篇:
C# SwapChain类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap