Beispiel #1
0
        // Detects the underlying OS and runtime.
        internal static void Init(ToolkitOptions options)
        {
            lock (InitLock)
            {
                if (!initialized)
                {
                    RunningOnMono    = DetectMono();
                    RunningOnWindows = DetectWindows();
                    RunningOnAndroid = DetectAndroid();
                    RunningOnIOS     = DetectIOS();

                    if (!RunningOnWindows)
                    {
                        DetectUnix(out runningOnUnix, out runningOnLinux, out runningOnMacOS);
                    }

                    // This will stop the LinuxFactory from loading on Android.
                    if (RunningOnAndroid)
                    {
                        runningOnLinux = false;
                    }

                    if (RunningOnIOS)
                    {
                        runningOnMacOS = false;
                    }

                    if (!RunningOnAndroid && (options.Backend == PlatformBackend.Default))
                    {
                        RunningOnSdl2 = DetectSdl2();
                    }

                    if ((runningOnLinux && !RunningOnSdl2) || options.Backend == PlatformBackend.PreferX11)
                    {
                        RunningOnX11 = DetectX11();
                    }

                    initialized = true;

                    Debug.Print("Detected configuration: {0} / {1}",
                                RunningOnWindows ? "Windows" : RunningOnLinux ? "Linux" : RunningOnMacOS ? "MacOS" :
                                RunningOnIOS ? "iOS" : RunningOnAndroid ? "Android" :
                                RunningOnUnix ? "Unix" : RunningOnX11 ? "X11" : "Unknown Platform",
                                RunningOnMono ? "Mono" : ".Net");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes osuTK with the specified options. Use this method
        /// to influence the osuTK.Platform implementation that will be used.
        /// </summary>
        /// <remarks>
        /// <para>
        /// You *must* call this method if you are combining osuTK with a
        /// third-party windowing toolkit (e.g. GTK#). In this case, this should be the
        /// first method called by your application:
        /// <code>
        /// static void Main()
        /// {
        ///     using (osuTK.Toolkit.Init())
        ///     {
        ///      ...
        ///     }
        /// }
        /// </code>
        /// </para>
        /// <para>
        /// The reason is that some toolkits do not configure the underlying platform
        /// correctly or configure it in a way that is incompatible with osuTK.
        /// Calling this method first ensures that osuTK is given the chance to
        /// initialize itself and configure the platform correctly.
        /// </para>
        /// </remarks>
        /// <param name="options">A <c>ToolkitOptions</c> instance
        /// containing the desired options.</param>
        /// <returns>
        /// An IDisposable instance that you can use to dispose of the resources
        /// consumed by osuTK.
        /// </returns>
        public static Toolkit Init(ToolkitOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            lock (InitLock)
            {
                if (!initialized)
                {
                    initialized = true;
                    Configuration.Init(options);
                    Options = options;

                    // The actual initialization takes place in the
                    // platform-specific factory constructors.
                    toolkit = new Toolkit(new Factory());
                }
                return(toolkit);
            }
        }