Showing a UIViewController on an SDL based iOS project |
Tim Angus
Guest
|
Maybe this is useful for other people. It needs to be compiled as .mm in
order to be callable from C++. void PresentModalView( const char* viewName ) { SDL_SysWMinfo info; SDL_VERSION( &info.version ); if( SDL_GetWindowWMInfo( window, &info ) ) { UIWindow* uiWindow = (UIWindow*)info.info.uikit.window; UIView* view = [uiWindow.subviews objectAtIndex:0]; id nextResponder = [view nextResponder]; if( [nextResponder isKindOfClass:[UIViewController class]] ) { UIViewController* viewController = (UIViewController*)nextResponder; // You can do some terrifying things with Objective-C NSString* className = [NSString stringWithUTF8String:viewName]; Class ViewControllerClass = NSClassFromString(className); id subviewController = [[[ViewControllerClass alloc] initWithNibName:className bundle:nil] autorelease]; [viewController presentModalViewController: subviewController animated:YES]; } } } _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Showing a UIViewController on an SDL based iOS project |
Tim Angus
Guest
|
On Sun, 17 Jul 2011 07:56:14 -0700 michelleC wrote:
Hmm really? I can't seem to find it. I'm not sure it's really appropriate for SDL anyway. It should however be possible as it's likely to be a very common thing to want to do. Worth bunging in the wiki somewhere anyway; though I'm not sure where.
I guess this makes the assumption that there is only one window? The part I negelected to mention in my post is that "window" is an SDL_Window* global, but it could just as easily be a parameter. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Re: Showing a UIViewController on an SDL based iOS project |
michelleC
|
|
|||||||||||||||||
|
Showing a UIViewController on an SDL based iOS project |
Vittorio G.
Guest
|
That's exactly how I implemented my application; I have subclassed the sdlappuikitdelegate and created my objc frontend, then i call some code that instances a second uiwindow and fills it with a sdl context
More details here: http://code.google.com/p/hedgewars/source/browse/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m bye Vittorio On Sun, Jul 17, 2011 at 11:47 PM, michelleC wrote:
|
|||||||||||||
|
Re: Showing a UIViewController on an SDL based iOS project |
michelleC
|
Yep, I've seen your app , nice.
I originally used multiple windows, but it really breaks (model wise not technically) the ios implementation. I pretty easy to get hold of the sdl window and add view controllers to it, or get the encapsulated sdl view and add it to a view controller. Is there any particular reason you used freepascal?? Also I am very interested in your android experience, I am having a great deal of problems with our app because it uses software yuv12 textures, and runs into memory issues very quick. I have not been able to get sam's open gles 2 renderer to work, which should solve the problems. Here's one for the road as they say /* construct our view, passing in SDL's OpenGL configuration data */ view = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \ retainBacking: _this->gl_config.retained_backing \ rBits: _this->gl_config.red_size \ gBits: _this->gl_config.green_size \ bBits: _this->gl_config.blue_size \ aBits: _this->gl_config.alpha_size \ depthBits: _this->gl_config.depth_size]; data->view = view; UINavigationController *localNavigationController; RootViewController *rootViewController; rootViewController = [[RootViewController alloc] init]; SDLUIKitDelegate *appDelegate = [SDLUIKitDelegate sharedAppDelegate]; localNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; //rootViewController.view.opaque = YES; localNavigationController.view.alpha = 1.0; localNavigationController.modalPresentationStyle = UIModalPresentationFormSheet; [localNavigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; if (firstTime) { [appDelegate setSettingUp:NO]; [data->uiwindow addSubview: view ]; [data->uiwindow addSubview:localNavigationController.view]; printf("created two windows local first"); }else { [data->uiwindow addSubview:localNavigationController.view]; [data->uiwindow addSubview: view ]; printf("created two windows sdl second"); }
|
|||||||||||||||
|