
How to fix double change of screen resolution in Mac OS X
Posted Friday, 9 September, 2011 - 13:36 by doterax| Project: | The Open Toolkit library |
| Version: | 1.0.0-rc1 |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | open |
Jump to:
Description
In source file OpenTK/Platform/MacOS/AglContext.cs you can find this comment and code:
// 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, ref width, ref height); }
But you can fix this fix :-) if you call Agl.aglSetDrawable(aglContextHandle, IntPtr.Zero) BEFORE call Agl.aglSetFullScreen
My code of SetFullScreen
internal void SetFullScreen(CarbonWindowInfo info, int width, int height) { IntPtr display = GetQuartzDevice(info); IntPtr requestedMode = GetBestDisplayMode(display, width, height, 32); if(requestedMode == IntPtr.Zero) { Agl.aglSetFullScreen(aglContextHandle, width, height, 60, 0); } else { if (_lastMode == IntPtr.Zero) _lastMode = CG.DisplayCurrentMode(display); CG.DisplaySwitchToMode(display, requestedMode); Agl.aglSetDrawable(aglContextHandle, IntPtr.Zero); Agl.aglEnable(aglContextHandle, Agl.ParameterNames.AGL_FS_CAPTURE_SINGLE); Agl.aglSetFullScreen(aglContextHandle, 0, 0, 0, 0); Agl.aglSetCurrentContext(aglContextHandle); Agl.aglUpdateContext(aglContextHandle); } mIsFullscreen = true; }


Comments
#1
Nice catch!