Пример #1
0
        /// <summary>
        /// Builds the monitor cache (again if previously called).
        /// </summary>
        public static unsafe void BuildMonitorCache()
        {
            GLFWProvider.EnsureInitialized();

            if (!GLFWProvider.IsOnMainThread)
            {
                throw new InvalidOperationException("Only GLFW main thread can build the monitor cache.");
            }

            var newInfos       = new List <MonitorInfo>();
            var newIndexLookup = new Dictionary <IntPtr, int>();

            var monitors = GLFW.GetMonitorsRaw(out int monitorCount);

            for (int i = 0; i < monitorCount; i++)
            {
                var monitor = *(monitors + i);

                newInfos.Add(new MonitorInfo(new MonitorHandle((IntPtr)monitor)));
                newIndexLookup.Add((IntPtr)monitor, i);
            }

            _monitorInfos       = newInfos;
            _monitorIndexLookup = newIndexLookup;

            _isCacheBuilt = true;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NativeWindowSettings"/> class.
 /// </summary>
 public NativeWindowSettings()
 {
     unsafe
     {
         GLFWProvider.EnsureInitialized();
         CurrentMonitor = new MonitorHandle((IntPtr)GLFW.GetPrimaryMonitor());
     }
 }
Пример #3
0
        /// <summary>
        /// Checks wheter the cache has been built or builds it if it can.
        /// </summary>
        /// <returns>Wether the current cache is valid or not.</returns>
        public static unsafe bool CheckCache()
        {
            GLFWProvider.EnsureInitialized();

            if (!_isCacheBuilt && GLFWProvider.IsOnMainThread)
            {
                BuildMonitorCache();
            }

            if (!_isHookSet && GLFWProvider.IsOnMainThread)
            {
                GLFW.SetMonitorCallback(DpiMonitorCallback);
            }

            return(_isCacheBuilt);
        }