Beispiel #1
0
        internal void SetFullScreen(CarbonWindowInfo info, out int width, out int height)
        {
            CarbonGLNative wind = GetCarbonWindow(info);

            Debug.Print("Switching to full screen {0}x{1} on context {2}",
                        wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, Handle.Handle);

            CG.DisplayCapture(GetQuartzDevice(info));
            Agl.aglSetFullScreen(Handle.Handle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0);
            MakeCurrent(info);

            width  = wind.TargetDisplayDevice.Width;
            height = wind.TargetDisplayDevice.Height;

            // This is a weird hack to workaround a bug where the first time a context
            // is made fullscreen, we just end up with a blank screen.  So we undo it as fullscreen
            // and redo it as fullscreen.
            if (firstFullScreen == false)
            {
                firstFullScreen = true;
                UnsetFullScreen(info);
                SetFullScreen(info, out width, out height);
            }

            mIsFullscreen = true;
        }
        public override sealed bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
        {
            IntPtr num1 = QuartzDisplayDeviceDriver.HandleTo(device);
            IntPtr num2 = CG.DisplayCurrentMode(num1);

            if (!this.storedModes.ContainsKey(num1))
            {
                this.storedModes.Add(num1, num2);
            }
            CFArray cfArray = new CFArray(CG.DisplayAvailableModes(num1));

            for (int index = 0; index < cfArray.Count; ++index)
            {
                CFDictionary cfDictionary = new CFDictionary(cfArray[index]);
                int          num3         = (int)cfDictionary.GetNumberValue("Width");
                int          num4         = (int)cfDictionary.GetNumberValue("Height");
                int          num5         = (int)cfDictionary.GetNumberValue("BitsPerPixel");
                double       numberValue  = cfDictionary.GetNumberValue("RefreshRate");
                if (num3 == resolution.Width && num4 == resolution.Height && (num5 == resolution.BitsPerPixel && Math.Abs(numberValue - (double)resolution.RefreshRate) < 1E-06))
                {
                    if (!this.displaysCaptured.Contains(num1))
                    {
                        int num6 = (int)CG.DisplayCapture(num1);
                    }
                    CG.DisplaySwitchToMode(num1, cfArray[index]);
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        internal void SetFullScreen(CarbonWindowInfo info, out int width, out int height)
        {
            CarbonGLNative carbonWindow = this.GetCarbonWindow(info);
            int            num          = (int)CG.DisplayCapture(this.GetQuartzDevice(info));

            Agl.aglSetFullScreen(this.Handle.Handle, carbonWindow.TargetDisplayDevice.Width, carbonWindow.TargetDisplayDevice.Height, 0, 0);
            this.MakeCurrent((IWindowInfo)info);
            width  = carbonWindow.TargetDisplayDevice.Width;
            height = carbonWindow.TargetDisplayDevice.Height;
            if (!this.firstFullScreen)
            {
                this.firstFullScreen = true;
                this.UnsetFullScreen(info);
                this.SetFullScreen(info, out width, out height);
            }
            this.mIsFullscreen = true;
        }
Beispiel #4
0
        public bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
        {
            IntPtr display = displayMap[device];
            IntPtr currentModePtr = CG.DisplayCurrentMode(display);

            if (storedModes.ContainsKey(display) == false)
            {
                storedModes.Add(display, currentModePtr);        
            }

            IntPtr displayModesPtr = CG.DisplayAvailableModes(display);
            CFArray displayModes = new CFArray(displayModesPtr);

            for (int j = 0; j < displayModes.Count; j++)
            {
                CFDictionary dict = new CFDictionary(displayModes[j]);

                int width = (int)dict.GetNumberValue("Width");
                int height = (int)dict.GetNumberValue("Height");
                int bpp = (int)dict.GetNumberValue("BitsPerPixel");
                double freq = dict.GetNumberValue("RefreshRate");

                if (width == resolution.Width &&
                    height == resolution.Height &&
                    bpp == resolution.BitsPerPixel &&
                    System.Math.Abs(freq - resolution.RefreshRate) < 1e-6)
                {
                    if (displaysCaptured.Contains(display) == false)
                    {
                        CG.DisplayCapture(display);
                    }

                    Debug.Print("Changing resolution to {0}x{1}x{2}@{3}.", width, height, bpp, freq);

                    CG.DisplaySwitchToMode(display, displayModes[j]);

                    return true;
                }

            }
            return false;
        }