示例#1
0
        public IGraphicsDevice CreateDevice(DotGame.Graphics.DeviceCreationFlags flags)
        {
            if (graphicsDevice != null)
            {
                return(graphicsDevice);
            }

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

            Device    device;
            SwapChain swapChain;

            Device.CreateWithSwapChain(DriverType.Hardware, EnumConverter.Convert(flags), swapChainDescription, out device, out swapChain);

            Factory factory = swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(control.Handle, WindowAssociationFlags.IgnoreAll);

            graphicsDevice = new GraphicsDevice(this, device, swapChain, flags);
            return(graphicsDevice);
        }
示例#2
0
 public Dx11ChainedDevice(Adapter adapter, SwapChainDescription descriptor)
 {
     Device.CreateWithSwapChain(adapter, GetDeviceCreationFlags(), descriptor, out _device, out _swapChain);
 }