]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
agl: experimental code to enumerate video modes (untested, uncompiled)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 5 Aug 2009 18:13:34 +0000 (18:13 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 5 Aug 2009 18:13:34 +0000 (18:13 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9094 d7cf8633-e32d-0410-b094-e92efae38249

vid_agl.c

index 97c36dbfd80e2cd376fb58b5aaa96686e4c3afdc..b08b10dd8ce4c483f5a908c326d2aa0bf7843d8b 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -629,7 +629,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
 
                // TOCHECK: not sure whether or not it's necessary to change the resolution
                // "by hand", or if aglSetFullscreen does the job anyway
-               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRate(mainDisplay, bpp, *width, *height, refreshrate, NULL);
+               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(mainDisplay, bpp, *width, *height, refreshrate, kCGDisplayModeIsSafeForHardware, NULL);
                CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
                DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
 
@@ -1124,5 +1124,28 @@ void IN_Move (void)
 
 size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)
 {
-       return 0; // FIXME implement this
+       CFArrayRef vidmodes = CGDisplayAvailableModes(mainDisplay);
+       CFDictionaryRef thismode;
+       unsigned int n = CFArrayGetCount(vidmodes);
+       unsigned int i;
+       size_t k;
+
+       k = 0;
+       for(i = 0; i < n; ++i)
+       {
+               thismode = (CFDictionaryRef) CFArrayGetValueAtIndex(vidmodes, i);
+               if(!GetDictionaryBoolean(thismode, kCGDisplayModeIsSafeForHardware))
+                       continue;
+
+               if(k >= maxcount)
+                       break;
+               modes[k].width = GetDictionaryLong(thismode, kCGDisplayWidth);
+               modes[k].height = GetDictionaryLong(thismode, kCGDisplayHeight);
+               modes[k].bpp = GetDictionaryLong(thismode, kCGDisplayBitsPerPixel);
+               modes[k].refreshrate = GetDictionaryLong(thismode, kCGDisplayRefreshRate);
+               modes[k].pixelheight_num = 1;
+               modes[k].pixelheight_denom = 1; // OS X doesn't expose this either
+               ++k;
+       }
+       return k;
 }