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, ContextHandle); CG.CGDisplayCapture(GetQuartzDevice(info)); byte code = Agl.aglSetFullScreen(ContextHandle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0); Agl.CheckReturnValue(code, "aglSetFullScreen"); 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) { firstFullScreen = true; UnsetFullScreen(info); SetFullScreen(info, out width, out height); } mIsFullscreen = true; }
internal void SetFullScreen(CarbonWindow wind, out int width, out int height) { int displayWidth = wind.Display.Bounds.Width; int displayHeight = wind.Display.Bounds.Height; Debug.Print("Switching to full screen {0}x{1} on context {2}", displayWidth, displayHeight, ContextHandle); CG.CGDisplayCapture(CG.CGMainDisplayID()); byte code = Agl.aglSetFullScreen(ContextHandle, displayWidth, displayHeight, 0, 0); Agl.CheckReturnValue(code, "aglSetFullScreen"); MakeCurrent(wind); width = displayWidth; height = displayHeight; // 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) { firstFullScreen = true; UnsetFullScreen(wind); SetFullScreen(wind, out width, out height); } mIsFullscreen = true; }
public bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { IntPtr display = displayMap[device]; IntPtr currentModePtr = CG.CGDisplayCurrentMode(display); if (!storedModes.ContainsKey(display)) { storedModes.Add(display, currentModePtr); } IntPtr displayModesPtr = CG.CGDisplayAvailableModes(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 && Math.Abs(freq - resolution.RefreshRate) < 1e-6) { if (!displaysCaptured.Contains(display)) { CG.CGDisplayCapture(display); } Debug.Print("Changing resolution to {0}x{1}x{2}@{3}.", width, height, bpp, freq); CG.CGDisplaySwitchToMode(display, displayModes[j]); return(true); } } return(false); }