src/video/uikit/SDL_uikitopengles.m
changeset 6521 f36bbe0a10c9
parent 6518 42948831d16e
child 6885 700f1b25f77f
child 8314 24f2de48557b
equal deleted inserted replaced
6520:7a7726af31c1 6521:f36bbe0a10c9
   130     view->viewcontroller = data->viewcontroller;
   130     view->viewcontroller = data->viewcontroller;
   131     if (view->viewcontroller != nil) {
   131     if (view->viewcontroller != nil) {
   132         [view->viewcontroller setView:view];
   132         [view->viewcontroller setView:view];
   133         [view->viewcontroller retain];
   133         [view->viewcontroller retain];
   134     }
   134     }
       
   135     [uiwindow addSubview: view];
   135     
   136     
   136     // The view controller needs to be the root in order to control rotation on iOS 6.0
   137     // The view controller needs to be the root in order to control rotation on iOS 6.0
   137     if (uiwindow.rootViewController == nil) {
   138     if (uiwindow.rootViewController == nil) {
   138         uiwindow.rootViewController = view->viewcontroller;
   139         uiwindow.rootViewController = view->viewcontroller;
   139     } else {
       
   140         [uiwindow addSubview: view];
       
   141     }
   140     }
   142 
   141 
   143     if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
   142     if (UIKit_GL_MakeCurrent(_this, window, view) < 0) {
   144         UIKit_GL_DeleteContext(_this, view);
   143         UIKit_GL_DeleteContext(_this, view);
   145         return NULL;
   144         return NULL;
   146     }
   145     }
   147 
   146 
   148     /* Make this window the current mouse focus for touch input */
   147     /* Make this window the current mouse focus for touch input */
   157 void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
   156 void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
   158 {
   157 {
   159     /* the delegate has retained the view, this will release him */
   158     /* the delegate has retained the view, this will release him */
   160     SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
   159     SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
   161     if (view->viewcontroller) {
   160     if (view->viewcontroller) {
       
   161         UIWindow *uiwindow = (UIWindow *)view.superview;
       
   162         if (uiwindow.rootViewController == view->viewcontroller) {
       
   163             uiwindow.rootViewController = nil;
       
   164         }
   162         [view->viewcontroller setView:nil];
   165         [view->viewcontroller setView:nil];
   163         [view->viewcontroller release];
   166         [view->viewcontroller release];
   164     }
   167     }
   165     [view removeFromSuperview];
   168     [view removeFromSuperview];
   166     [view release];
   169     [view release];