예제 #1
0
 private static RenderControl CreateRenderControl(RenderingBackend backend)
 {
     if (backend == RenderingBackend.Vulkan)
     {
         return(new VulkanRenderControl());
     }
     else
     {
         var flags = backend == RenderingBackend.ES20
                                 ? OpenTK.Graphics.GraphicsContextFlags.Embedded
                                 : OpenTK.Graphics.GraphicsContextFlags.Default;
         return(new OpenGLRenderControl(new OpenTK.Graphics.GraphicsMode(32, 16, 8), 2, 0, flags));
     }
 }
예제 #2
0
        public static void Initialize(ApplicationOptions options = null)
        {
            // System.Environment.SetEnvironmentVariable("METAL_DEVICE_WRAPPER_TYPE", "1");
#if MAC
            NSApplication.Init();
            NSApplication.SharedApplication.ApplicationShouldTerminate += (sender) => {
                return(DoExiting() ? NSApplicationTerminateReply.Now : NSApplicationTerminateReply.Cancel);
            };
            NSApplication.SharedApplication.WillTerminate += (sender, e) => DoExited();
            NSApplication.SharedApplication.ApplicationShouldHandleReopen = (sender, hasVisibleWindows) => hasVisibleWindows;
#endif // MAC
            options          = options ?? new ApplicationOptions();
            RenderingBackend = options.RenderingBackend;
            MainThread       = Thread.CurrentThread;
            // Use '.' as decimal separator.
            var culture = System.Globalization.CultureInfo.InvariantCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture         = culture;
            System.Globalization.CultureInfo.DefaultThreadCurrentCulture = culture;
            AudioSystem.Initialize(options);
#if WIN
            System.Windows.Forms.Application.EnableVisualStyles();
            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Windows.Forms.Application.SetUnhandledExceptionMode(
                    System.Windows.Forms.UnhandledExceptionMode.ThrowException);
            }
            else
            {
                SetGlobalExceptionHandler();
                System.Windows.Forms.Application.SetUnhandledExceptionMode(
                    System.Windows.Forms.UnhandledExceptionMode.CatchException);
            }
            // This function doesn't work on XP, and we don't want to add dpiAware into manifest
            // because this will require adding into every new project.
            try {
                SetProcessDPIAware();
            } catch (EntryPointNotFoundException ex) {
                Logger.Write(ex.Message);
            }
            SoftKeyboard = new DummySoftKeyboard();
#elif MAC
            SoftKeyboard = new DummySoftKeyboard();
#elif iOS
            System.IO.Directory.SetCurrentDirectory(Foundation.NSBundle.MainBundle.ResourcePath);
            UIApplication.SharedApplication.StatusBarHidden   = true;
            UIApplication.SharedApplication.IdleTimerDisabled = !IsAllowedGoingToSleepMode();
#endif // WIN
        }