getDPI for Mac Implemented

This commit is contained in:
Sridher Jakku 2015-08-03 17:12:52 +05:30
parent 6a2440d6f1
commit f48a9fb9f0
1 changed files with 7 additions and 2 deletions

View File

@ -36,8 +36,13 @@ NS_CC_BEGIN
int Device::getDPI()
{
//TODO: return correct DPI
return 160;
NSScreen *screen = [NSScreen mainScreen];
NSDictionary *description = [screen deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize(
[[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
return ((displayPixelSize.width / displayPhysicalSize.width) * 25.4f);
}
void Device::setAccelerometerEnabled(bool isEnabled)