Program.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Linq;
  3. using Avalonia;
  4. using Avalonia.Logging;
  5. using Drawie.Interop.Avalonia;
  6. using Drawie.Interop.VulkanAvalonia;
  7. using PixiEditor.Helpers;
  8. namespace PixiEditor.Desktop;
  9. public class Program
  10. {
  11. // Initialization code. Don't use any Avalonia, third-party APIs or any
  12. // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
  13. // yet and stuff might break.
  14. [STAThread]
  15. public static void Main(string[] args) => BuildAvaloniaApp()
  16. .StartWithClassicDesktopLifetime(args);
  17. // Avalonia configuration, don't remove; also used by visual designer.
  18. public static AppBuilder BuildAvaloniaApp()
  19. {
  20. bool openGlPreferred = false;
  21. try
  22. {
  23. openGlPreferred = string.Equals(RenderApiPreferenceManager.TryReadRenderApiPreference(), "opengl",
  24. StringComparison.OrdinalIgnoreCase);
  25. if (!openGlPreferred)
  26. {
  27. var cmdArgs = Environment.GetCommandLineArgs();
  28. if (cmdArgs is { Length: > 0 })
  29. {
  30. openGlPreferred = cmdArgs.Any(arg =>
  31. string.Equals(arg, "--opengl", StringComparison.OrdinalIgnoreCase));
  32. }
  33. }
  34. }
  35. catch (Exception ex)
  36. {
  37. }
  38. return AppBuilder.Configure<App>()
  39. .UsePlatformDetect()
  40. .With(new Win32PlatformOptions()
  41. {
  42. RenderingMode = openGlPreferred ? [ Win32RenderingMode.Wgl, Win32RenderingMode.Vulkan] : [ Win32RenderingMode.Vulkan, Win32RenderingMode.Wgl],
  43. OverlayPopups = true,
  44. })
  45. .With(new X11PlatformOptions()
  46. {
  47. RenderingMode = openGlPreferred ? [ X11RenderingMode.Glx, X11RenderingMode.Vulkan] : [ X11RenderingMode.Vulkan, X11RenderingMode.Glx],
  48. OverlayPopups = true,
  49. })
  50. .With(new SkiaOptions()
  51. {
  52. MaxGpuResourceSizeBytes = 1024 * 600 * 4 * 12 * 4 // quadruple the default size
  53. })
  54. .WithDrawie()
  55. #if DEBUG
  56. .LogToTrace(LogEventLevel.Verbose, "Vulkan")
  57. #endif
  58. .LogToTrace();
  59. }
  60. }