Exemple #1
0
        private static SharpDX.WIC.BitmapSource LoadBitmap(Stream stream, out SharpDX.WIC.BitmapDecoder decoder)
        {
            if (imgfactory == null)
            {
                imgfactory = new SharpDX.WIC.ImagingFactory();
            }
			
			SharpDX.WIC.FormatConverter fconv = null;
			
            decoder = new SharpDX.WIC.BitmapDecoder(
                imgfactory,
                stream,
                SharpDX.WIC.DecodeOptions.CacheOnDemand
                );

			fconv = new SharpDX.WIC.FormatConverter(imgfactory);

			fconv.Initialize(
				decoder.GetFrame(0),
				SharpDX.WIC.PixelFormat.Format32bppPRGBA,
				SharpDX.WIC.BitmapDitherType.None, null,
				0.0, SharpDX.WIC.BitmapPaletteType.Custom);

			return fconv;
        }
        public ProjectorCameraEnsemble(int numProjectors, int numCameras)
        {
            projectors = new List<ProjectorCameraEnsemble.Projector>();
            for (int i = 0; i < numProjectors; i++)
            {
                var projector = new ProjectorCameraEnsemble.Projector();
                projector.name = i.ToString();
                projector.hostNameOrAddress = "localhost";
                projectors.Add(projector);
            }
            cameras = new List<ProjectorCameraEnsemble.Camera>();
            for (int i = 0; i < numCameras; i++)
            {
                var camera = new ProjectorCameraEnsemble.Camera();
                camera.name = i.ToString();
                camera.hostNameOrAddress = "localhost";
                cameras.Add(camera);

                if (i == 0)
                    camera.pose = RoomAliveToolkit.Matrix.Identity(4, 4);
            }
            name = "Untitled";

            imagingFactory = new SharpDX.WIC.ImagingFactory();
            stopWatch = new System.Diagnostics.Stopwatch();
        }
Exemple #3
0
        public InfoText(SharpDX.Direct3D11.Device device, int width, int height)
        {
            _immediateContext = device.ImmediateContext;
            _rect.Size        = new Size2F(width, height);
            _bitmapSize       = width * height * 4;
            IsEnabled         = true;

            using (var factoryWic = new SharpDX.WIC.ImagingFactory())
            {
                _wicBitmap = new SharpDX.WIC.Bitmap(factoryWic,
                                                    width, height, _pixelFormat, SharpDX.WIC.BitmapCreateCacheOption.CacheOnLoad);
            }

            var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default,
                                                                    new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                                                                                                      SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None,
                                                                    SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT);

            using (var factory2D = new SharpDX.Direct2D1.Factory())
            {
                _wicRenderTarget = new WicRenderTarget(factory2D, _wicBitmap, renderTargetProperties);
                _wicRenderTarget.TextAntialiasMode = TextAntialiasMode.Default;
            }

            using (var factoryDWrite = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared))
            {
                _textFormat = new TextFormat(factoryDWrite, "Tahoma", 20);
            }

            Color4 color = new Color4(1, 1, 1, 1);

            _sceneColorBrush  = new SolidColorBrush(_wicRenderTarget, color);
            _clearColor       = color;
            _clearColor.Alpha = 0;

            _renderTexture = new Texture2D(device, new Texture2DDescription()
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.ShaderResource,
                CpuAccessFlags    = CpuAccessFlags.Write,
                Format            = Format.R8G8B8A8_UNorm,
                Height            = height,
                Width             = width,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Dynamic
            });

            OverlayBufferView = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
            {
                Format    = _renderTexture.Description.Format,
                Dimension = ShaderResourceViewDimension.Texture2D,
                Texture2D = new ShaderResourceViewDescription.Texture2DResource()
                {
                    MipLevels       = 1,
                    MostDetailedMip = 0
                }
            });
        }
Exemple #4
0
 public void Dispose()
 {
     if (stream != null)
     {
         stream.Dispose();
         stream = null;
     }
     if (d2dRenderTarget != null)
     {
         d2dRenderTarget.Dispose();
         d2dRenderTarget = null;
     }
     if (wicBitmap != null)
     {
         wicBitmap.Dispose();
         wicBitmap = null;
     }
     if (d2dFactory != null)
     {
         d2dFactory.Dispose();
         d2dFactory = null;
     }
     if (wicFactory != null)
     {
         wicFactory.Dispose();
         wicFactory = null;
     }
     if (memStream != null)
     {
         memStream.Dispose();
     }
 }
        public InfoText(SharpDX.Direct3D11.Device device, int width, int height)
        {
            _immediateContext = device.ImmediateContext;
            _rect.Size = new Size2F(width, height);
            _bitmapSize = width * height * 4;
            IsEnabled = true;

            using (var factoryWic = new SharpDX.WIC.ImagingFactory())
            {
                _wicBitmap = new SharpDX.WIC.Bitmap(factoryWic,
                    width, height, _pixelFormat, SharpDX.WIC.BitmapCreateCacheOption.CacheOnLoad);
            }

            var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default,
                new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                    SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None,
                    SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT);

            using (var factory2D = new SharpDX.Direct2D1.Factory())
            {
                _wicRenderTarget = new WicRenderTarget(factory2D, _wicBitmap, renderTargetProperties);
                _wicRenderTarget.TextAntialiasMode = TextAntialiasMode.Default;
            }

            using (var factoryDWrite = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared))
            {
                _textFormat = new TextFormat(factoryDWrite, "Tahoma", 20);
            }

            Color4 color = new Color4(1, 1, 1, 1);
            _sceneColorBrush = new SolidColorBrush(_wicRenderTarget, color);
            _clearColor = color;
            _clearColor.Alpha = 0;

            _renderTexture = new Texture2D(device, new Texture2DDescription()
            {
                ArraySize = 1,
                BindFlags = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.Write,
                Format = Format.R8G8B8A8_UNorm,
                Height = height,
                Width = width,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Dynamic
            });

            OverlayBufferRes = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
            {
                Format = _renderTexture.Description.Format,
                Dimension = ShaderResourceViewDimension.Texture2D,
                Texture2D = new ShaderResourceViewDescription.Texture2DResource()
                {
                    MipLevels = 1,
                    MostDetailedMip = 0
                }
            });
        }
        public CapturePlayback(SharpDX.Direct2D1.Device device, SharpDX.WIC.ImagingFactory factory, CapturePlayer player)
        {
            this.player = player;
            context     = new DeviceContext(device, DeviceContextOptions.EnableMultithreadedOptimizations);

            CurrentFrame = player.CurrentSurface.Select(surface => CreateFrame(surface));
            this.factory = factory;
        }
        internal static void InitializeDirect2D()
        {
            lock (s_initLock)
            {
                if (s_initialized)
                {
                    return;
                }
#if DEBUG
                try
                {
                    Direct2D1Factory = new SharpDX.Direct2D1.Factory1(
                        SharpDX.Direct2D1.FactoryType.MultiThreaded,
                        SharpDX.Direct2D1.DebugLevel.Error);
                }
                catch
                {
                    //
                }
#endif
                if (Direct2D1Factory == null)
                {
                    Direct2D1Factory = new SharpDX.Direct2D1.Factory1(
                        SharpDX.Direct2D1.FactoryType.MultiThreaded,
                        SharpDX.Direct2D1.DebugLevel.None);
                }

                using (var factory = new SharpDX.DirectWrite.Factory())
                {
                    DirectWriteFactory = factory.QueryInterface <SharpDX.DirectWrite.Factory1>();
                }

                ImagingFactory = new SharpDX.WIC.ImagingFactory();

                var featureLevels = new[]
                {
                    SharpDX.Direct3D.FeatureLevel.Level_11_1,
                    SharpDX.Direct3D.FeatureLevel.Level_11_0,
                    SharpDX.Direct3D.FeatureLevel.Level_10_1,
                    SharpDX.Direct3D.FeatureLevel.Level_10_0,
                    SharpDX.Direct3D.FeatureLevel.Level_9_3,
                    SharpDX.Direct3D.FeatureLevel.Level_9_2,
                    SharpDX.Direct3D.FeatureLevel.Level_9_1,
                };

                Direct3D11Device = new SharpDX.Direct3D11.Device(
                    SharpDX.Direct3D.DriverType.Hardware,
                    SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport | SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport,
                    featureLevels);

                DxgiDevice = Direct3D11Device.QueryInterface <SharpDX.DXGI.Device1>();

                Direct2D1Device = new SharpDX.Direct2D1.Device(Direct2D1Factory, DxgiDevice);

                s_initialized = true;
            }
        }
Exemple #8
0
        public StreamPlayback(SharpDX.Direct2D1.Device device, SharpDX.WIC.ImagingFactory factory, StreamPlayer player, TimeSpan?duration)
        {
            this.player = player;
            context     = new DeviceContext(device, DeviceContextOptions.EnableMultithreadedOptimizations);
            Duration    = duration;

            CurrentFrame = player.CurrentTime.Select(time => CreateFrame(player.Surface, time)).DisposeCurrentOnNext();
            this.factory = factory;
        }
Exemple #9
0
 public ExternalRenderTarget(
     IExternalDirect2DRenderTargetSurface externalRenderTargetProvider,
     DirectWriteFactory dwFactory,
     SharpDX.WIC.ImagingFactory wicFactory)
 {
     _externalRenderTargetProvider = externalRenderTargetProvider;
     _dwFactory  = dwFactory;
     _wicFactory = wicFactory;
 }
Exemple #10
0
        //TODO: check this way to getting back texture
        //public BitmapSource ToBitmap() {
        //    if (_d3D11Image == null)
        //        return null;

        //    // Copy back buffer to WriteableBitmap.
        //    int width = _d3D11Image.PixelWidth;
        //    int height = _d3D11Image.PixelHeight;
        //    var format = EnableAlpha ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
        //    var writeableBitmap = new WriteableBitmap(width, height, 96, 96, format, null);
        //    writeableBitmap.Lock();
        //    try {
        //        uint[] data = new uint[width * height];
        //        _d3D11Image.TryGetData(data);

        //        // Get a pointer to the back buffer.
        //        unsafe {
        //            uint* pBackbuffer = (uint*)writeableBitmap.BackBuffer;
        //            for (int i = 0; i < data.Length; i++)
        //                pBackbuffer[i] = data[i];
        //        }

        //        writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, width, height));
        //    } finally {
        //        writeableBitmap.Unlock();
        //    }

        //    return writeableBitmap;
        //}


        static void Copy(Texture2D texture, Stream stream, SharpDX.Direct3D11.Device device)
        {
            var desc = new Texture2DDescription {
                Width             = (int)texture.Description.Width,
                Height            = (int)texture.Description.Height,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = texture.Description.Format,
                Usage             = ResourceUsage.Staging,
                SampleDescription = new SampleDescription(1, 0),
                BindFlags         = BindFlags.None,
                CpuAccessFlags    = CpuAccessFlags.Read,
                OptionFlags       = ResourceOptionFlags.None
            };



            using (var factory = new SharpDX.WIC.ImagingFactory()) {
                using (var textureCopy = new Texture2D(device, desc)) {
                    device.ImmediateContext.CopyResource(texture, textureCopy);

                    var dataBox = device.ImmediateContext.MapSubresource(
                        textureCopy,
                        0,
                        0,
                        MapMode.Read,
                        global::SharpDX.Direct3D11.MapFlags.None,
                        out SharpDX.DataStream dataStream);
                    using (dataStream) {
                        var t = dataStream.ReadByte(); //ReadFloat();

                        var dataRectangle = new SharpDX.DataRectangle {
                            DataPointer = dataStream.DataPointer,
                            Pitch       = dataBox.RowPitch
                        };
                        //https://github.com/sharpdx/Toolkit/blob/master/Source/Toolkit/SharpDX.Toolkit.Graphics/WICHelper.cs
                        using (var bitmap = new SharpDX.WIC.Bitmap(factory, textureCopy.Description.Width, textureCopy.Description.Height,
                                                                   SharpDX.WIC.PixelFormat.Format32bppRGBA, dataRectangle, 0)) {
                            stream.Position = 0;
                            using (var bitmapEncoder = new SharpDX.WIC.PngBitmapEncoder(factory, stream)) {
                                using (var bitmapFrameEncode = new SharpDX.WIC.BitmapFrameEncode(bitmapEncoder)) {
                                    bitmapFrameEncode.Initialize();
                                    bitmapFrameEncode.SetSize(bitmap.Size.Width, bitmap.Size.Height);
                                    var pixelFormat = SharpDX.WIC.PixelFormat.FormatDontCare;
                                    bitmapFrameEncode.SetPixelFormat(ref pixelFormat);
                                    bitmapFrameEncode.WriteSource(bitmap);
                                    bitmapFrameEncode.Commit();
                                    bitmapEncoder.Commit();
                                }
                            }
                        }
                        device.ImmediateContext.UnmapSubresource(textureCopy, 0);
                    }
                }
            }
        }
Exemple #11
0
 public DXGI2DContext(int width, int height)
 {
     this.width             = width;
     this.height            = height;
     wicFactory             = new SharpDX.WIC.ImagingFactory();
     d2dFactory             = new SharpDX.Direct2D1.Factory();
     wicBitmap              = new SharpDX.WIC.Bitmap(wicFactory, width, height, SharpDX.WIC.PixelFormat.Format32bppBGR, SharpDX.WIC.BitmapCreateCacheOption.CacheOnLoad);
     renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new PixelFormat(Format.Unknown, AlphaMode.Unknown), 0, 0, RenderTargetUsage.None, SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT);
     d2dRenderTarget        = new WicRenderTarget(d2dFactory, wicBitmap, renderTargetProperties);
 }
Exemple #12
0
 static D2dFactory()
 {
     if (Environment.OSVersion.Version.Major < 6)
     {
         throw new Exception("Direct2D requires Windows Vista or newer");
     }
     s_d2dFactory = new SharpDX.Direct2D1.Factory();
     s_dwFactory  = new SharpDX.DirectWrite.Factory();
     s_wicFactory = new SharpDX.WIC.ImagingFactory();
 }
Exemple #13
0
        /// <summary>
        /// 创建图片
        /// </summary>
        /// <param name="wicFactory"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        static SharpDX.WIC.FormatConverter CreateWicImage(SharpDX.WIC.ImagingFactory wicFactory, string fileName)
        {
            using var decoder      = new SharpDX.WIC.JpegBitmapDecoder(wicFactory);
            using var decodeStream = new SharpDX.WIC.WICStream(wicFactory, fileName, SharpDX.IO.NativeFileAccess.Read);
            decoder.Initialize(decodeStream, SharpDX.WIC.DecodeOptions.CacheOnLoad);
            using var decodeFrame = decoder.GetFrame(0);
            var converter = new SharpDX.WIC.FormatConverter(wicFactory);

            converter.Initialize(decodeFrame, SharpDX.WIC.PixelFormat.Format32bppPBGRA);
            return(converter);
        }
Exemple #14
0
        public static SharpDX.Direct2D1.Bitmap LoadFromFile(string filePath)
        {
            SharpDX.WIC.ImagingFactory  imagingFactory = new SharpDX.WIC.ImagingFactory();
            SharpDX.IO.NativeFileStream fileStream     = new SharpDX.IO.NativeFileStream(filePath,
                                                                                         SharpDX.IO.NativeFileMode.Open, SharpDX.IO.NativeFileAccess.Read);

            SharpDX.WIC.BitmapDecoder bitmapDecoder =
                new SharpDX.WIC.BitmapDecoder(imagingFactory, fileStream, SharpDX.WIC.DecodeOptions.CacheOnDemand);
            SharpDX.WIC.BitmapFrameDecode frame = bitmapDecoder.GetFrame(0);

            SharpDX.WIC.FormatConverter converter = new SharpDX.WIC.FormatConverter(imagingFactory);
            converter.Initialize(frame, SharpDX.WIC.PixelFormat.Format32bppPRGBA);

            return(SharpDX.Direct2D1.Bitmap.FromWicBitmap(RenderForm.RenderTarget, converter));
        }
Exemple #15
0
        /// <summary>
        /// 保存图片
        /// </summary>
        /// <param name="wicFactory"></param>
        /// <param name="wicBitmap"></param>
        /// <param name="outputStream"></param>
        static void SaveD2DBitmap(SharpDX.WIC.ImagingFactory wicFactory, SharpDX.WIC.Bitmap wicBitmap, Stream outputStream)
        {
            using var encoder = new SharpDX.WIC.BitmapEncoder(wicFactory, SharpDX.WIC.ContainerFormatGuids.Png);
            encoder.Initialize(outputStream);
            using var frame = new SharpDX.WIC.BitmapFrameEncode(encoder);
            frame.Initialize();
            frame.SetSize(wicBitmap.Size.Width, wicBitmap.Size.Height);

            var pixelFormat = wicBitmap.PixelFormat;

            frame.SetPixelFormat(ref pixelFormat);
            frame.WriteSource(wicBitmap);
            frame.Commit();
            encoder.Commit();
        }
Exemple #16
0
 Bitmap GetBitmap(RenderTarget target, Stream stream)
 {
     using (SharpDX.WIC.ImagingFactory wicFactory = new SharpDX.WIC.ImagingFactory())
     {
         using (SharpDX.WIC.BitmapDecoder bmpDecoder = new SharpDX.WIC.BitmapDecoder(wicFactory, stream, SharpDX.WIC.DecodeOptions.CacheOnLoad))
         {
             using (SharpDX.WIC.FormatConverter converter = new SharpDX.WIC.FormatConverter(wicFactory))
             {
                 using (SharpDX.WIC.BitmapFrameDecode frameDecode = bmpDecoder.GetFrame(0))
                 {
                     converter.Initialize(frameDecode, SharpDX.WIC.PixelFormat.Format32bppBGR);
                     return(SharpDX.Direct2D1.Bitmap.FromWicBitmap(target, converter));
                 }
             }
         }
     }
 }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DrawingContextImpl"/> class.
 /// </summary>
 /// <param name="visualBrushRenderer">The visual brush renderer.</param>
 /// <param name="renderTarget">The render target to draw to.</param>
 /// <param name="layerFactory">
 /// An object to use to create layers. May be null, in which case a
 /// <see cref="WicRenderTargetBitmapImpl"/> will created when a new layer is requested.
 /// </param>
 /// <param name="directWriteFactory">The DirectWrite factory.</param>
 /// <param name="imagingFactory">The WIC imaging factory.</param>
 /// <param name="swapChain">An optional swap chain associated with this drawing context.</param>
 /// <param name="finishedCallback">An optional delegate to be called when context is disposed.</param>
 public DrawingContextImpl(
     IVisualBrushRenderer visualBrushRenderer,
     ILayerFactory layerFactory,
     SharpDX.Direct2D1.RenderTarget renderTarget,
     SharpDX.DirectWrite.Factory directWriteFactory,
     SharpDX.WIC.ImagingFactory imagingFactory,
     SharpDX.DXGI.SwapChain1 swapChain = null,
     Action finishedCallback           = null)
 {
     _visualBrushRenderer = visualBrushRenderer;
     _layerFactory        = layerFactory;
     _renderTarget        = renderTarget;
     _swapChain           = swapChain;
     _finishedCallback    = finishedCallback;
     _directWriteFactory  = directWriteFactory;
     _imagingFactory      = imagingFactory;
     _renderTarget.BeginDraw();
 }
Exemple #18
0
        public Direct2DGraphics(int width, int height)
            : this()
        {
            var wicFactory = new SharpDX.WIC.ImagingFactory();

            bitmap = DisposeLater(new SharpDX.WIC.Bitmap(
                                      wicFactory,
                                      width, height,
                                      SharpDX.WIC.PixelFormat.Format32bppPBGRA,
                                      SharpDX.WIC.BitmapCreateCacheOption.CacheOnDemand));
            dc = DisposeLater(new WicRenderTarget(
                                  d2dFactory,
                                  bitmap,
                                  new RenderTargetProperties(
                                      RenderTargetType.Default,
                                      new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied),
                                      d2dFactory.DesktopDpi.Width, d2dFactory.DesktopDpi.Height,
                                      RenderTargetUsage.None,
                                      FeatureLevel.Level_DEFAULT)));

            Initialize();
        }
Exemple #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrintControl"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="wicFactory">The WIC factory.</param>
 /// <param name="documentTarget">The document target.</param>
 /// <unmanaged>HRESULT ID2D1Device::CreatePrintControl([In] IWICImagingFactory* wicFactory,[In] IPrintDocumentPackageTarget* documentTarget,[In, Optional] const D2D1_PRINT_CONTROL_PROPERTIES* printControlProperties,[Out] ID2D1PrintControl** printControl)</unmanaged>
 public PrintControl(Device device, SharpDX.WIC.ImagingFactory wicFactory, SharpDX.ComObject documentTarget)
 {
     device.CreatePrintControl(wicFactory, documentTarget, null, this);
 }
 public PlatformPlayer(AvService avService, SharpDX.Direct2D1.Device d2DDevice, SharpDX.WIC.ImagingFactory factory)
 {
     underlyingPlayer = avService.GetStreamPlayer(gpu: true);
     Playback         = underlyingPlayer.Duration
                        .Select(duration => new StreamPlayback(d2DDevice, factory, underlyingPlayer, duration))
                        .DisposeCurrentOnNext();
 }
Exemple #21
0
 /// <summary>
 /// Initialize a new instance of the <see cref="BitmapImpl"/> class
 /// with a bitmap backed by GPU memory.
 /// </summary>
 /// <param name="d2DBitmap">The GPU bitmap.</param>
 /// <remarks>
 /// This bitmap must be either from the same render target,
 /// or if the render target is a <see cref="SharpDX.Direct2D1.DeviceContext"/>,
 /// the device associated with this context, to be renderable.
 /// </remarks>
 public D2DBitmapImpl(WICFactory imagingFactory, Bitmap d2DBitmap)
     : base(imagingFactory)
 {
     _direct2D = d2DBitmap ?? throw new ArgumentNullException(nameof(d2DBitmap));
 }
Exemple #22
0
        internal static void Init()
        {
            Logger.Info("GraphicsManager initializing.");

            // Direct3D11 Init ---
            ResizeNextFrame = true;

            Factory        = new FactoryDXGI();
            ImagingFactory = new FactoryWIC();
            Factory2D      = new FactoryD2D(FactoryType.MultiThreaded,
                                            Engine.IsDebug ? DebugLevel.Error : DebugLevel.None);
            DirectWriteFactory = new FactoryDW(SharpDX.DirectWrite.FactoryType.Shared);

            CreateDevices(RenderSettings.GraphicsAdapter);

            Brushes =
                new MemoizingMRUCache <Colour, SolidColorBrush>(
                    (colour, _) => new SolidColorBrush(Context2D, (Color4)colour)
            {
                Opacity = colour.A
            }, int.MaxValue,
                    brush => brush.Dispose());
            // ------------------------------------

            Engine.HandleSet += hwnd =>
            {
                var camera = Game.Workspace.CurrentCamera;
                camera.RenderHandle = hwnd;
            };

            if (Engine.Handle != IntPtr.Zero)
            {
                var camera = Game.Workspace.CurrentCamera;
                camera.RenderHandle = Engine.Handle;
            }

            SamplerStates.Load();
            Shaders.Init();
            BlendStates.Load();
            DepthStencilStates.Load();
            RasterizerStates.Load();

            //StandardConstants = new ConstantBuffer<StandardConstantData>();

            StandardShader = Shaders.Get("Standard");
            MainPass       = StandardShader.GetPass();
            LightingShader = Shaders.Get("Lighting");
            LightingPass   = LightingShader.GetPass();

            PostProcessShader = Shaders.Get("PostProcess");

            SkyboxShader = Shaders.Get("Skybox");
            SkyboxPass   = SkyboxShader.GetPass();

            AdornShader      = Shaders.Get("Adorn");
            AALinePass       = AdornShader.GetPass("AALine");
            AdornSelfLitPass = AdornShader.GetPass("AdornSelfLit");

            Shadows.Init();

            // ------------------

            IsInitialized = true;
            Initialized?.Invoke();
            Initialized = null;

            //PixHelper.AllowProfiling(Engine.IsDebug);

            Logger.Info("Renderer initialized.");
        }
 void OnDeserialized(StreamingContext c)
 {
     imagingFactory = new SharpDX.WIC.ImagingFactory();
     stopWatch = new System.Diagnostics.Stopwatch();
 }
Exemple #24
-1
 /// <unmanaged>HRESULT ID2D1Device::CreatePrintControl([In] IWICImagingFactory* wicFactory,[In] IPrintDocumentPackageTarget* documentTarget,[In, Optional] const D2D1_PRINT_CONTROL_PROPERTIES* printControlProperties,[Out] ID2D1PrintControl** printControl)</unmanaged>
 public PrintControl(Device device, SharpDX.WIC.ImagingFactory wicFactory, SharpDX.ComObject documentTarget, SharpDX.Direct2D1.PrintControlProperties rintControlPropertiesRef)
 {
     device.CreatePrintControl(wicFactory, documentTarget, rintControlPropertiesRef, this);
 }