mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-11 17:59:02 +00:00
Fixed: #1004 updated get display modes implementation to use more current apis
This commit is contained in:
parent
7f007d2cc1
commit
a13981f0ad
1 changed files with 31 additions and 25 deletions
|
@ -16,15 +16,19 @@ using namespace NL3D;
|
||||||
namespace NL3D
|
namespace NL3D
|
||||||
{
|
{
|
||||||
|
|
||||||
static int numberForKey( CFDictionaryRef desc, CFStringRef key )
|
static int bppFromDisplayMode(CGDisplayModeRef mode)
|
||||||
{
|
{
|
||||||
CFNumberRef value;
|
CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
|
||||||
int num = 0;
|
|
||||||
|
if(CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels),
|
||||||
|
kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
||||||
|
return 32;
|
||||||
|
|
||||||
|
else if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels),
|
||||||
|
kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
||||||
|
return 16;
|
||||||
|
|
||||||
if ( (value = (CFNumberRef)CFDictionaryGetValue(desc, key)) == NULL )
|
|
||||||
return 0;
|
return 0;
|
||||||
CFNumberGetValue(value, kCFNumberIntType, &num);
|
|
||||||
return num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getMacModes(std::vector<GfxMode> &modes)
|
bool getMacModes(std::vector<GfxMode> &modes)
|
||||||
|
@ -40,41 +44,43 @@ bool getMacModes(std::vector<GfxMode> &modes)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nldebug("3D: %d displays found\n", (int)numDisplays);
|
nldebug("3D: %d displays found", (int)numDisplays);
|
||||||
|
|
||||||
for (CGDisplayCount i = 0; i < numDisplays; ++i)
|
for (CGDisplayCount i = 0; i < numDisplays; ++i)
|
||||||
{
|
{
|
||||||
CGDirectDisplayID dspy = display[i];
|
CGDirectDisplayID dspy = display[i];
|
||||||
|
CFArrayRef modeList = CGDisplayCopyAllDisplayModes(dspy, NULL);
|
||||||
|
|
||||||
CFArrayRef modeList = CGDisplayAvailableModes(dspy);
|
|
||||||
if (modeList == NULL)
|
if (modeList == NULL)
|
||||||
{
|
{
|
||||||
nlwarning("Display is invalid");
|
nlwarning("Display is invalid");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CFIndex cnt = CFArrayGetCount(modeList);
|
|
||||||
nldebug("3D: Display 0x%x has %d modes:", (unsigned int)dspy, (int)cnt);
|
|
||||||
for (CFIndex j = 0; j < cnt; ++j)
|
|
||||||
{
|
|
||||||
CFDictionaryRef desc = (CFDictionaryRef)CFArrayGetValueAtIndex(modeList, j);
|
|
||||||
|
|
||||||
int w = numberForKey(desc, kCGDisplayWidth);
|
for (CFIndex j = 0; j < CFArrayGetCount(modeList); ++j)
|
||||||
int h = numberForKey(desc, kCGDisplayHeight);
|
{
|
||||||
int bpp = numberForKey(desc, kCGDisplayBitsPerPixel);
|
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, j);
|
||||||
int freq = numberForKey(desc, kCGDisplayRefreshRate);
|
int bpp = bppFromDisplayMode(mode);
|
||||||
|
|
||||||
if (bpp >= 16)
|
if (bpp >= 16)
|
||||||
{
|
{
|
||||||
|
int w = CGDisplayModeGetWidth(mode);
|
||||||
|
int h = CGDisplayModeGetHeight(mode);
|
||||||
|
|
||||||
// Add this mode
|
// Add this mode
|
||||||
GfxMode mode;
|
GfxMode mode;
|
||||||
mode.Width = (uint16)w;
|
mode.Width = (uint16)w;
|
||||||
mode.Height = (uint16)h;
|
mode.Height = (uint16)h;
|
||||||
mode.Depth = (uint8)bpp;
|
mode.Depth = (uint8)bpp;
|
||||||
mode.Frequency = freq;
|
|
||||||
modes.push_back (mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
nldebug( " > Mode %d: %dx%d, %d BPP, %d Hz", j, w, h, bpp, freq);
|
// frequency stays at 0 because on mac cocoa, display resolution
|
||||||
|
// is never really changed. if rendering resolution < display resolution
|
||||||
|
// cocoa interpolates and keeps the display at it's original resolution
|
||||||
|
mode.Frequency = 0;
|
||||||
|
modes.push_back (mode);
|
||||||
|
|
||||||
|
nldebug( " Display 0x%x: Mode %dx%d, %d BPP", dspy, w, h, bpp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue