Beispiel #1
0
        public static void Initialize()
        {
            AvaloniaLocator.CurrentMutable.Bind <IPlatformOpenGlInterface>().ToLazy <IPlatformOpenGlInterface>(() =>
            {
                var opts = AvaloniaLocator.Current.GetService <Win32PlatformOptions>();
                if (opts?.UseWgl == true)
                {
                    var wgl = WglPlatformOpenGlInterface.TryCreate();
                    return(wgl);
                }

                if (opts?.AllowEglInitialization == true)
                {
                    var egl = EglPlatformOpenGlInterface.TryCreate(() => new AngleWin32EglDisplay());

                    if (egl is { } &&
                        opts?.UseWindowsUIComposition == true)
                    {
                        var compositionConnector = CompositionConnector.TryCreate(egl);

                        if (compositionConnector != null)
                        {
                            AvaloniaLocator.CurrentMutable.BindToSelf(compositionConnector);
                        }
                    }

                    return(egl);
                }
 public IBlurHost AttachToCompositionTree(CompositionConnector connector, IntPtr hwnd)
 {
     using (_egl.PrimaryContext.MakeCurrent())
     {
         _surfaceInterop = connector.InitialiseWindowCompositionTree(hwnd, out _surface, out var blurHost);
         return(blurHost);
     }
 }