diff --git a/EarthViewExample-Info.plist b/EarthViewExample-Info.plist index 2b19ea5..97caa7f 100644 --- a/EarthViewExample-Info.plist +++ b/EarthViewExample-Info.plist @@ -41,8 +41,8 @@ armv7 - UIStatusBarHidden - + UIStatusBarStyle + UIStatusBarStyleBlackTranslucent UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/EarthViewExample.xcodeproj/project.xcworkspace/xcuserdata/ross.xcuserdatad/UserInterfaceState.xcuserstate b/EarthViewExample.xcodeproj/project.xcworkspace/xcuserdata/ross.xcuserdatad/UserInterfaceState.xcuserstate index 0670ca7..d2192b2 100644 Binary files a/EarthViewExample.xcodeproj/project.xcworkspace/xcuserdata/ross.xcuserdatad/UserInterfaceState.xcuserstate and b/EarthViewExample.xcodeproj/project.xcworkspace/xcuserdata/ross.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/RASceneGraphController.m b/Source/RASceneGraphController.m index 189c53f..c5b5607 100644 --- a/Source/RASceneGraphController.m +++ b/Source/RASceneGraphController.m @@ -143,14 +143,14 @@ - (void)viewDidLoad // setup auxillary context for threaded texture loading operations if ( _pager && ! _pager.auxilliaryContext ) _pager.auxilliaryContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:[_context sharegroup]]; - [_pager setupGL]; // register for notifications if ( _camera ) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayNotification:) name:RACameraStateChangedNotification object:_camera]; if ( _pager ) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayNotification:) name:RATilePagerContentChangedNotification object:_pager]; + _needsUpdate = YES; + _needsDisplay = YES; [self setupGL]; - [self update]; } - (void)viewDidUnload @@ -245,7 +245,6 @@ - (IBAction)flyToLocationFrom:(id)sender { #pragma mark - UITextFieldDelegate - (BOOL)textFieldShouldClear:(UITextField *)textField { - NSLog(@"Clear!"); return YES; } @@ -273,6 +272,7 @@ - (RANode *)createSceneGraphForPager:(RATilePager *)pager - (void)setupGL { [EAGLContext setCurrentContext:_context]; + [glView bindDrawable]; glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -302,10 +302,7 @@ - (void)setupGL [_renderVisitor setupGL]; } - [self update]; - - _needsUpdate = YES; - _needsDisplay = YES; + [_pager setupGL]; } - (void)tearDownGL @@ -329,11 +326,11 @@ - (void)update _renderVisitor.lightPosition = lightEcef; } - self.camera.viewport = self.view.bounds; + self.camera.viewport = self.glView.bounds; [_camera calculateProjectionForBounds: self.sceneRoot.bound]; // update skybox projection - float aspect = fabsf(self.view.bounds.size.width / self.view.bounds.size.height); + float aspect = fabsf(self.glView.bounds.size.width / self.glView.bounds.size.height); GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(_camera.fieldOfView), aspect, 10, 50); _skybox.transform.projectionMatrix = projectionMatrix; _skybox.transform.modelviewMatrix = self.camera.modelViewMatrix; @@ -376,8 +373,7 @@ - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect [RAGeometry cleanupAll:NO]; // show stats - if ( statsLabel ) - [statsLabel setText:_renderVisitor.statsString]; + [statsLabel setText:_renderVisitor.statsString]; } @end diff --git a/Source/RATilePager.m b/Source/RATilePager.m index 22b2fe3..7e8a8a2 100644 --- a/Source/RATilePager.m +++ b/Source/RATilePager.m @@ -336,13 +336,22 @@ - (void)requestPage:(RAPage *)page { NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if ( error ) { - // attempt to reload if the connection timed out - if ( [[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorTimedOut ) { - page.imageryState = NotLoaded; - return; + // catch common errors + if ( [[error domain] isEqualToString:NSURLErrorDomain] ) { + switch( [error code] ) { + case NSURLErrorTimedOut: + // attempt to reload if the connection timed out + page.imageryState = NotLoaded; + return; + case NSURLErrorNotConnectedToInternet: // !!! catch other common errors here + // give up if net access is unavailable + page.imageryState = Failed; + return; + default: break; + } } - - NSLog(@"URL loading error): %@", error); + + NSLog(@"URL loading error: %@", error); page.imageryState = Failed; return; } else if ( [[response MIMEType] isEqualToString:@"text/html"] ) { @@ -399,13 +408,22 @@ - (void)requestPage:(RAPage *)page { NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if ( error ) { - // attempt to reload if the connection timed out - if ( [[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorTimedOut ) { - page.terrainState = NotLoaded; - return; + // catch common errors + if ( [[error domain] isEqualToString:NSURLErrorDomain] ) { + switch( [error code] ) { + case NSURLErrorTimedOut: + // attempt to reload if the connection timed out + page.terrainState = NotLoaded; + return; + case NSURLErrorNotConnectedToInternet: // !!! catch other common errors here + // give up if net access is unavailable + page.terrainState = Failed; + return; + default: break; + } } - - NSLog(@"URL Error loading (%@): %@", url, error); + + NSLog(@"URL loading error: %@", error); page.terrainState = Failed; return; } else if ( [[response MIMEType] isEqualToString:@"text/html"] ) { @@ -509,28 +527,23 @@ - (void)requestUpdate { return; } - [self update]; -} - -- (void)update { - - NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate]; - // capture self to avoid a retain cycle __block RATilePager *mySelf = self; [_updateQueue addOperationWithBlock:^{ + [mySelf traverse]; + }]; +} + +- (void)traverse { + NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate]; + + do { // traverse pages gathering ones that are active and should be displayed - [mySelf->rootPages enumerateObjectsUsingBlock:^(RAPage *page, BOOL *stop) { - [mySelf traversePage:page withTimestamp:currentTime]; + [rootPages enumerateObjectsUsingBlock:^(RAPage *page, BOOL *stop) { + [self traversePage:page withTimestamp:currentTime]; }]; - - // update again if changes were made during traverse - if ( mySelf->_updateAgain ) { - mySelf->_updateAgain = NO; - [mySelf update]; - } - }]; + } while( _updateAgain ); // update again if changes were made } @end diff --git a/en.lproj/SceneView_iPad.xib b/en.lproj/SceneView_iPad.xib index badea86..89d2e22 100644 --- a/en.lproj/SceneView_iPad.xib +++ b/en.lproj/SceneView_iPad.xib @@ -1,22 +1,22 @@ - 1296 + 1536 11E53 - 2182 + 2541 1138.47 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 + 1875 - IBUITextField + IBGLKView + IBProxyObject IBUILabel IBUISwitch + IBUITextField IBUIView - IBGLKView - IBProxyObject com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -41,7 +41,7 @@ 274 - {768, 1028} + {768, 1024} @@ -51,8 +51,8 @@ 4 YES IBIPadFramework + 1 2 - 1 NO @@ -61,22 +61,14 @@ {{507, 20}, {241, 31}} - + _NS:9 NO YES IBIPadFramework 0 - 3 Fly to Location - - 3 - MAA - - 2 - - YES 17 @@ -90,6 +82,14 @@ fly 1 + + + 3 + MAA + + 2 + + 1 14 @@ -103,7 +103,7 @@ 268 - {{20, 951}, {525, 33}} + {{20, 971}, {525, 33}} @@ -113,11 +113,6 @@ 7 NO IBIPadFramework - Statistics - - 1 - MSAxIDEAA - 1 @@ -125,7 +120,12 @@ {1, 1} 0 - 10 + 0.5 + Statistics + + 1 + MSAxIDEAA + 1 24 @@ -135,11 +135,12 @@ 24 16 + 1 265 - {{553, 951}, {105, 33}} + {{553, 971}, {105, 33}} @@ -149,8 +150,6 @@ 7 NO IBIPadFramework - Culling: - 1 @@ -158,25 +157,27 @@ {1, 1} 0 - 10 + 0.5 + Culling: + 2 + 1 265 - {{553, 916}, {105, 33}} + {{553, 936}, {105, 33}} + _NS:9 NO YES 7 NO IBIPadFramework - Paging: - 1 @@ -184,15 +185,18 @@ {1, 1} 0 - 10 + 0.5 + Paging: + 2 + 1 265 - {{654, 954}, {94, 27}} + {{654, 974}, {94, 27}} _NS:9 @@ -205,7 +209,7 @@ 265 - {{654, 919}, {94, 27}} + {{654, 939}, {94, 27}} @@ -217,7 +221,7 @@ YES - {768, 1004} + {768, 1024} @@ -226,6 +230,22 @@ 1 MCAwIDAAA + + IBUIScreenMetrics + + YES + + + + + + {768, 1024} + {1024, 768} + + + IBIPadFramework + iPad Full Screen + IBIPadFramework @@ -285,7 +305,7 @@ - 25 + 40 @@ -387,7 +407,7 @@ - 39 + 40 @@ -443,16 +463,12 @@ 0 IBIPadFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - YES 3 fly {16, 16} - 1181 + 1875 diff --git a/en.lproj/SceneView_iPhone.xib b/en.lproj/SceneView_iPhone.xib index 745e981..9cc8728 100644 --- a/en.lproj/SceneView_iPhone.xib +++ b/en.lproj/SceneView_iPhone.xib @@ -1,20 +1,20 @@ - 1296 + 1536 11E53 - 2182 + 2541 1138.47 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 + 1875 - IBUITextField - IBUIView IBGLKView IBProxyObject + IBUITextField + IBUIView com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -49,8 +49,8 @@ 4 YES IBCocoaTouchFramework + 1 2 - 1 NO @@ -59,22 +59,13 @@ {{20, 20}, {280, 31}} - _NS:9 NO YES IBCocoaTouchFramework 0 - 3 Fly to Location - - 3 - MAA - - 2 - - YES 17 @@ -88,6 +79,14 @@ fly 1 + + + 3 + MAA + + 2 + + 1 14 @@ -99,7 +98,7 @@ - {320, 460} + {{0, 20}, {320, 460}} @@ -108,6 +107,25 @@ 1 MCAwIDAAA + + 1 + + + IBUIScreenMetrics + + YES + + + + + + {320, 480} + {480, 320} + + + IBCocoaTouchFramework + iPhone/iPod touch Full Screen + IBCocoaTouchFramework @@ -208,7 +226,7 @@ - 23 + 24 @@ -227,10 +245,17 @@ + UISwitch UITextField GLKView + UISwitch + UILabel + + clippingEnable + UISwitch + flyToLocationField UITextField @@ -239,6 +264,14 @@ glView GLKView + + pagingEnable + UISwitch + + + statsLabel + UILabel + IBProjectSource @@ -251,7 +284,7 @@ IBCocoaTouchFramework com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - + YES 3 @@ -259,6 +292,6 @@ fly {16, 16} - 1181 + 1875