diff --git a/openVulkanoCpp/Host/iOS/OpenVulkanoOrientationLockableViewController.mm b/openVulkanoCpp/Host/iOS/OpenVulkanoOrientationLockableViewController.mm index 744b4b8..7fb3a4b 100644 --- a/openVulkanoCpp/Host/iOS/OpenVulkanoOrientationLockableViewController.mm +++ b/openVulkanoCpp/Host/iOS/OpenVulkanoOrientationLockableViewController.mm @@ -29,6 +29,17 @@ } } +-(CGFloat)getOrientation { + if (_rotationLockedView == nil) return 0; + return [[_rotationLockedView.layer valueForKeyPath:@"transform.rotation.z"] floatValue]; +} + +-(void)setOrientation:(CGFloat)angle { + if (_rotationLockedView != nil) { + [_rotationLockedView.layer setValue:@(angle) forKeyPath:@"transform.rotation.z"]; + } +} + -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; @@ -38,10 +49,10 @@ CGAffineTransform deltaTransform = coordinator.targetTransform; CGFloat deltaAngle = atan2f(deltaTransform.b, deltaTransform.a); - CGFloat currentRotation = [[_rotationLockedView.layer valueForKeyPath:@"transform.rotation.z"] floatValue]; + CGFloat currentRotation = [self getOrientation]; // Adding a small value to the rotation angle forces the animation to occur in a the desired direction, preventing an issue where the view would appear to rotate 2PI radians during a rotation from LandscapeRight -> LandscapeLeft. currentRotation += -1 * deltaAngle + 0.0001; - [_rotationLockedView.layer setValue:@(currentRotation) forKeyPath:@"transform.rotation.z"]; + [self setOrientation:currentRotation]; } completion:^(id context) { // Integralize the transform to undo the extra 0.0001 added to the rotation angle. diff --git a/openVulkanoCpp/Host/iOS/OpenVulkanoViewController.h b/openVulkanoCpp/Host/iOS/OpenVulkanoViewController.h index 0a9e20b..29f24e8 100644 --- a/openVulkanoCpp/Host/iOS/OpenVulkanoViewController.h +++ b/openVulkanoCpp/Host/iOS/OpenVulkanoViewController.h @@ -16,6 +16,8 @@ @property (nonatomic, strong) OpenVulkanoView* openVulkanoView; +-(id)init; + -(void*) makeGraphicsApp; @end @@ -24,4 +26,12 @@ @property (nonatomic, strong) UIView* rotationLockedView; +//@property CGFloat baseRotation; + +-(id)init; + +-(CGFloat)getOrientation; + +-(void)setOrientation:(CGFloat)angle; + @end