Beispiel #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);
        }
Beispiel #2
0
 public static SharpDX.Direct3D11.DeviceCreationFlags Convert(DotGame.Graphics.DeviceCreationFlags flags)
 {
     SharpDX.Direct3D11.DeviceCreationFlags f = 0;
     if (flags.HasFlag(DotGame.Graphics.DeviceCreationFlags.Debug))
     {
         f |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
     }
     return(f);
 }
Beispiel #3
0
        internal GraphicsDevice(IGameWindow window, Device device, SwapChain swapChain, DeviceCreationFlags creationFlags)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (device.IsDisposed)
            {
                throw new ObjectDisposedException("device");
            }
            if (swapChain == null)
            {
                throw new ArgumentNullException("swapChain");
            }
            if (swapChain.IsDisposed)
            {
                throw new ObjectDisposedException("swapChain");
            }


            this.DefaultWindow = window;
            this.Device        = device;
            this.swapChain     = swapChain;
            this.CreationFlags = CreationFlags;

            this.CreatedObjects = new List <GraphicsObject>();

            this.Device.DebugName = string.Format("{0}@{1:X}", GetType().FullName, ((object)this).GetHashCode());
            this.Factory          = new GraphicsFactory(this);
            this.RenderContext    = new RenderContext(this, device.ImmediateContext);

            this.Capabilities = new GraphicsCapabilities()
            {
                SupportsBinaryShaders = true
            };

            InitBackbuffer();
        }