I'm making a game and I'd like to get a list of valid fullscreen resolutions for the launcher. I can't find any way of doing this for Mac OS X;
Like in the system preferences Displays
pane.
Is it possible?
I'm making a game and I'd like to get a list of valid fullscreen resolutions for the launcher. I can't find any way of doing this for Mac OS X;
Like in the system preferences Displays
pane.
Is it possible?
If you mean get the Display screen resolutions.
This may be what you are after.
NSScreen* thescreen;
id theScreens = [NSScreen screens];
for (thescreen in theScreens) {
NSLog(@"%@x%@", [NSNumber numberWithFloat:[thescreen frame].size.width], [NSNumber numberWithFloat:[thescreen frame].size.height]);
}
This example will give you the set resolutions of all displays
Have a look at apples NSScreen
If this is not quite what you are after can you expand your question.
Cheers
This maybe what you are after and you will have to play with it to see if it is indeed returning the correct info. I was getting multiple results hence the filter. But if you play with it you should be able to thin it down.
The test project was using ARC and it forced the __bridges.. But again I am sure you will have time to code it all better.
My reference was Quartz Display Services Reference
NSArray* theref = (__bridge NSArray *)(CGDisplayCopyAllDisplayModes ( CGMainDisplayID(), nil ));
NSMutableArray * rezes = [[NSMutableArray alloc]init];
for (id aMode in theref) {
CGDisplayModeRef thisMode = (__bridge CGDisplayModeRef)(aMode);
size_t theWidth = CGDisplayModeGetWidth( thisMode );
size_t theHeight = CGDisplayModeGetHeight( thisMode );
NSString *theRez = [NSString stringWithFormat:@"%zux%zu",theWidth,theHeight];
if (![rezes containsObject:theRez]) {
[rezes addObject:theRez];
}
}
NSLog(@" display deatails = %@", rezes);
-->
display deatails = (
2560x1440,
1280x720,
640x480,
800x600,
1024x768,
1280x1024,
1344x756,
1600x900,
1680x1050,
1920x1080,
1600x1200,
1920x1200
)
kCGDisplayShowDuplicateLowResolutionModes
instead of nil in CGDisplayCopyAllDisplayModes
? It said to get all possible resolutions but i am getting same as if i pass nil
. –
Stump In C++ http://specialmeaning.blogspot.com/2016/07/yes-apple-i-did-it.html
#include <iostream>
#include <CoreGraphics/CoreGraphics.h>
int main(int argc, const char * argv[]) {
// insert code here...
auto mainDisplayId = CGMainDisplayID();
std::cout << "Current resolution was "
<< CGDisplayPixelsWide(mainDisplayId) << 'x'
<< CGDisplayPixelsHigh(mainDisplayId) << std::endl
<< "Supported resolution modes:";
auto modes = CGDisplayCopyAllDisplayModes(mainDisplayId, nullptr);
auto count = CFArrayGetCount(modes);
CGDisplayModeRef mode;
for(auto c=count;c--;){
mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, c);
auto w = CGDisplayModeGetWidth(mode);
auto h = CGDisplayModeGetHeight(mode);
std::cout << std::endl << w << 'x' << h;
}
CGDisplaySetDisplayMode(mainDisplayId, mode, nullptr);
std::cout << " is the selected top one." << std::endl;
std::cin.get();
return 0;
}
© 2022 - 2024 — McMap. All rights reserved.