iOS上sdl使用方法:
1)、官网上下载文件后再docs->readme.ios文档里记载的
4、Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iOS provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically.
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell Xcode not to use the project prefix file, as it includes Objective-C code.
首先需要删除app delegate.h .m文件,因为sol提供自己的UIApplicationDelegate,同时删除MainWindow,并在info.plist删除(其实不删除也行,只要从main函数入口进入时,入口处删除默认进入程序的代码,也就不会进入默认的appdelegate)
然后删除main.m文件里的内容,将int main(int argc, char * argv[]替换成extern C_LINKAGE int SDL_main(int argc, char * argv[])。
extern C_LINKAGE int SDL_main(int argc, char * argv[])
{
@autoreleasepool {
ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[UIApplication sharedApplication].keyWindow.rootViewController = viewController;
[[UIApplication sharedApplication].keyWindow makeKeyAndVisible];
return 0;
}
}
遇到的问题:
1)不按上面的方法做,直接通过默认方式进入控制器,使用sdl_init初始化,就会初始化不成功,原因是没有在入口main函数中调用sdl_main函数。但如果不改变main.m文件中int main(int argc, char * argv[]为extern C_LINKAGE int SDL_main(int argc, char * argv[]),就需要在main.m文件里先进行sdl_init初始化