diff --git a/example-basic/example-basic.xcodeproj/project.xcworkspace/xcuserdata/joschow1.xcuserdatad/UserInterfaceState.xcuserstate b/example-basic/example-basic.xcodeproj/project.xcworkspace/xcuserdata/joschow1.xcuserdatad/UserInterfaceState.xcuserstate index 899352b..a5734c8 100644 Binary files a/example-basic/example-basic.xcodeproj/project.xcworkspace/xcuserdata/joschow1.xcuserdatad/UserInterfaceState.xcuserstate and b/example-basic/example-basic.xcodeproj/project.xcworkspace/xcuserdata/joschow1.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/src/ARCam.mm b/src/ARCam.mm index 4f70d5f..3cb5d8d 100644 --- a/src/ARCam.mm +++ b/src/ARCam.mm @@ -19,12 +19,13 @@ } void ARCam::setup(bool debugMode){ + nativeDimensions = ARCommon::getDeviceDimensions(); ambientIntensity = 0.0; orientation = UIInterfaceOrientationPortrait; shouldBuildCameraFrame = true; this->debugMode = debugMode; needsPerspectiveAdjustment = false; - viewportSize = CGSizeMake(ofGetWindowWidth(), ofGetWindowHeight()); + viewportSize = CGSizeMake(nativeDimensions.x,nativeDimensions.y); yTexture = NULL; CbCrTexture = NULL; near = 0.01; diff --git a/src/ARUtils.h b/src/ARUtils.h index 6698c87..603af57 100644 --- a/src/ARUtils.h +++ b/src/ARUtils.h @@ -51,6 +51,53 @@ namespace ARCommon { } + static ofVec2f getDeviceDimensions(){ + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + + ofVec2f dimensions; + + + switch(UIDevice.currentDevice.orientation){ + case UIDeviceOrientationFaceUp: + break; + + case UIDeviceOrientationFaceDown: + break; + case UIInterfaceOrientationUnknown: + dimensions.x = screenBounds.size.width; + dimensions.y = screenBounds.size.height; + + break; + + // upside down registers, but for some reason nothing happens :/ + // leaving this here anyways. + case UIInterfaceOrientationPortraitUpsideDown: + dimensions.x = screenBounds.size.width; + dimensions.y = screenBounds.size.height; + + break; + + case UIInterfaceOrientationPortrait: + dimensions.x = screenBounds.size.width; + dimensions.y = screenBounds.size.height; + + + break; + + case UIInterfaceOrientationLandscapeLeft: + dimensions.x = screenBounds.size.height; + dimensions.y = screenBounds.size.width; + + break; + + case UIInterfaceOrientationLandscapeRight: + dimensions.x = screenBounds.size.height; + dimensions.y = screenBounds.size.width; + break; + } + + return dimensions; + } //! Gets the official resolution of the device you're currently using under the assumption that the width/height //! matches the current orientation your device is in(ie landscape gives longer width than portrait)