Exemple #1
0
 public D2D1MetaResource(CreationProperties props, Action <D2D1MetaResource <TDxgiContainer> > dxgiConnector,
                         Action <D2D1MetaResource <TDxgiContainer> > dxgiDisconnector)
 {
     this.m_creationProperties      = props;
     this.m_onDxgiDestroyedAction   = () => this.DestroyInternal(true);
     this.m_onDxgiInitializedAction = () => this.InitializeInternal(true);
     this.m_dxgiConnector           = dxgiConnector;
     this.m_dxgiDisconnector        = dxgiDisconnector;
 }
Exemple #2
0
        public static D2D1MetaResource <IDxgi1_2ContainerWithSwapChain> CreateForSwapChain(
            ThreadingMode threadingMode         = ThreadingMode.SingleThreaded,
            DeviceContextOptions contextOptions = DeviceContextOptions.EnableMultithreadedOptimizations,
            DebugLevel debugLevel = DebugLevel.None)
        {
            var props = new CreationProperties
            {
                DebugLevel    = debugLevel,
                ThreadingMode = threadingMode,
                Options       = contextOptions
            };

            return(CreateForSwapChainCore(ref props));
        }
Exemple #3
0
        private static D2D1MetaResource <IDxgi1Container> CreateCore(
            ref CreationProperties props)
        {
#if DEBUG
            // Note: These have no impact on solution outside
            // of this project. This is only for internal testing
            // purposes
            if (props.DebugLevel == 0)
            {
                props.DebugLevel = DebugLevel.Information;
            }
#endif
            return(new D2D1MetaResource <IDxgi1Container>(props, null, null));
        }
Exemple #4
0
            public D2D(Ref <Dxgi> dxgi)
            {
                Dxgi    = dxgi;
                Factory = default;
                Device  = default;
                Context = default;

                CreationProperties = new CreationProperties()
                {
                    Options       = DeviceContextOptions.EnableMultithreadedOptimizations,
                    ThreadingMode = ThreadingMode.SingleThreaded
                };
                DebugSelect(DebugLevel.Warning, DebugLevel.Error, out CreationProperties.DebugLevel);
            }
Exemple #5
0
        internal RenderTarget(RenderContext context, bool isRoot)
        {
            if (isRoot)
            {
                _backBuffer = context.SwapChain.GetBackBuffer <Texture2D>(0);
            }
            else
            {
                _backBuffer = new Texture2D(context.Direct3DDevice, new Texture2DDescription {
                    Format            = Format.B8G8R8A8_UNorm,
                    ArraySize         = 1,
                    MipLevels         = 1,
                    Width             = context.ClientSize.Width,
                    Height            = context.ClientSize.Height,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage             = ResourceUsage.Default,
                    BindFlags         = BindFlags.RenderTarget,
                    CpuAccessFlags    = CpuAccessFlags.None,
                    OptionFlags       = ResourceOptionFlags.Shared
                });
            }

            _backBufferSurface = _backBuffer.QueryInterface <Surface>();

            _renderView = new RenderTargetView(context.Direct3DDevice, _backBuffer);

            // Create the depth buffer
            _depthBuffer = new Texture2D(context.Direct3DDevice, new Texture2DDescription {
                Format            = Format.D24_UNorm_S8_UInt,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = context.ClientSize.Width,
                Height            = context.ClientSize.Height,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Default,
                BindFlags         = BindFlags.DepthStencil,
                CpuAccessFlags    = CpuAccessFlags.None,
                OptionFlags       = ResourceOptionFlags.None
            });

            // Create the depth buffer view.
            _depthView = new DepthStencilView(context.Direct3DDevice, _depthBuffer);

            var createProps = new CreationProperties();

            _deviceContext2D = new SharpDX.Direct2D1.DeviceContext(_backBufferSurface, createProps);

            DeviceContext3D = context.Direct3DDevice.ImmediateContext;
        }
Exemple #6
0
        private static D2D1MetaResource <IDxgi1_2ContainerWithSwapChain> CreateForSwapChainCore(
            ref CreationProperties props)
        {
#if DEBUG
            // Note: These have no impact on solution outside
            // of this project. This is only for internal testing
            // purposes
            if (props.DebugLevel == 0)
            {
                props.DebugLevel = DebugLevel.Information;
            }
#endif
            return(new D2D1MetaResource <IDxgi1_2ContainerWithSwapChain>(props, D2D1Helper.ConnectContextToDxgiSwapChain,
                                                                         D2D1Helper.DisconnectContextFromDxgiSwapChain));
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device"/> class.
 /// </summary>
 /// <param name="surface">The surface.</param>
 /// <param name="creationProperties">The creation properties.</param>
 /// <unmanaged>HRESULT D2D1CreateDeviceContext([In] IDXGISurface* dxgiSurface,[In, Optional] const D2D1_CREATION_PROPERTIES* creationProperties,[Out] ID2D1DeviceContext** d2dDeviceContext)</unmanaged>	
 public DeviceContext(SharpDX.DXGI.Surface surface, CreationProperties creationProperties)
     : base(IntPtr.Zero)
 {
     D2D1.CreateDeviceContext(surface, creationProperties, this);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="creationProperties">The creation properties.</param>
 /// <unmanaged>HRESULT D2D1CreateDevice([In] IDXGIDevice* dxgiDevice,[In, Optional] const D2D1_CREATION_PROPERTIES* creationProperties,[Out] ID2D1Device** d2dDevice)</unmanaged>
 public Device(SharpDX.DXGI.Device device, CreationProperties creationProperties)
     : base(IntPtr.Zero)
 {
     D2D1.CreateDevice(device, creationProperties, this);
 }        
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="creationProperties">The creation properties.</param>
 /// <unmanaged>HRESULT D2D1CreateDevice([In] IDXGIDevice* dxgiDevice,[In, Optional] const D2D1_CREATION_PROPERTIES* creationProperties,[Out] ID2D1Device** d2dDevice)</unmanaged>
 public Device(SharpDX.DXGI.Device device, CreationProperties creationProperties)
     : base(IntPtr.Zero)
 {
     D2D1.CreateDevice(device, creationProperties, this);
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device"/> class.
 /// </summary>
 /// <param name="surface">The surface.</param>
 /// <param name="creationProperties">The creation properties.</param>
 /// <unmanaged>HRESULT D2D1CreateDeviceContext([In] IDXGISurface* dxgiSurface,[In, Optional] const D2D1_CREATION_PROPERTIES* creationProperties,[Out] ID2D1DeviceContext** d2dDeviceContext)</unmanaged>
 public DeviceContext(SharpDX.DXGI.Surface surface, CreationProperties creationProperties)
     : base(IntPtr.Zero)
 {
     D2D1.CreateDeviceContext(surface, creationProperties, this);
 }
Exemple #11
0
 public static D2D1MetaResource <IDxgi1Container> Create(ref CreationProperties props)
 {
     return(CreateCore(ref props));
 }
Exemple #12
0
 public static D2D1MetaResource <IDxgi1_2ContainerWithSwapChain> CreateForSwapChain(ref CreationProperties props)
 {
     return(CreateForSwapChainCore(ref props));
 }