Skip to content

Commit

Permalink
ARCam + ARUtils changes.
Browse files Browse the repository at this point in the history
- add `getDeviceDimensions` which is essentially the same as `getDeviceNativeDimensions` but uses the `bounds` prop of `[UIScreen mainScreen]` instead of `nativeBounds`
- update `viewportSize` to follow Metal example
  • Loading branch information
Joseph Chow committed Sep 22, 2017
1 parent 6eb4873 commit 1993f06
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Binary file not shown.
3 changes: 2 additions & 1 deletion src/ARCam.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
47 changes: 47 additions & 0 deletions src/ARUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1993f06

Please sign in to comment.