0

-- I have this in my appdelegate.m among all the other default calls: --

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [self.window makeKeyAndVisible];
    NSLog(@"Launched");
    return YES;
}

-- My main.mm looks like this: --

#import <UIKit/UIKit.h>

#import "AppDelegate.h"
#include <allegro5/allegro.h>
ALLEGRO_DISPLAY *Display;

int main(int argc, char *argv[])
{
    al_init();
    al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS,
                           ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE,ALLEGRO_REQUIRE);
    Display = al_create_display(960, 640);
    printf("%d, %d", al_get_display_width(Display),                
                    al_get_display_height(Display));

    return 0;
}

As soon as i include allegro.h and all the required libraries/frameworks in my project and call al_init() inside main, the program stops printing "Launched". It seems like the AppDelegate is being ignored totally. Anyone got any tips ???

  • override -(void)applicationDidBecomeActive:(UIApplication *)application in AppDelegate and put a NSLog in there to see if it's getting there. Then you know it's getting to App Delegate if you debug prints. – apollosoftware.org Mar 15 '13 at 15:52
  • you can also look at -(void)applicationWillEnterForeground:(UIApplication *)application – apollosoftware.org Mar 15 '13 at 15:54

3 Answers3

0

instead of returning 0 you should set an integer return value:

   int retVal = UIApplicationMain(argc, argv, nil, nil);
   return retVal;

or

   return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

That may work.

apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69
  • I tried return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); ///---/// The app compiles but gives this as output: ///---/// *** Assertion failure in void UIApplicationInstantiateSingleton(Class)(), /SourceCache/UIKit_Sim/UIKit-2380.17/UIApplication.m:2037 *** Terminating app due to uncaught exception
    'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
    – Anton Korhonen Mar 15 '13 at 16:18
  • did the first one, UIApplicationMain(argc, argv, nil, nil); produce different results? – apollosoftware.org Mar 15 '13 at 16:19
  • What did you mean by overriding applicationDidBecomeActive? Do i have to create a subclass of UIApplicationDelegate and then override the method of the superclass (in his case UIApplicationDelegate)? I'm a beginner iOS programmer. – Anton Korhonen Mar 15 '13 at 16:26
  • No just add that to your AppDelegate.m and put NSLog(@"Launched"); in there to see if the app is reaching your AppDelegate at all. – apollosoftware.org Mar 15 '13 at 16:28
  • Well i have tried. Actually i have placed NSLog to every one of the methods in AppDelegate.h (applicationDidEnterBackground, applicationWillEnterForeground, etc.). Nothing comes to the output. – Anton Korhonen Mar 15 '13 at 16:30
0

Allegro programs are meant to be cross platform at the source code level. Thus you do not need to provide an AppDelegate, as Allegro already does that. OS events will be converted into Allegro events that you can respond to in a cross platform way.

If you really need your own AppDelegate, then you'd need to edit Allegro's source code.

Matthew
  • 47,584
  • 11
  • 86
  • 98
0

Allegro 5.1 didn't have the rootViewController set. I modified the allegro source code to do that and everything works now on iOS 6.0/6.1.

I added shouldAutorotate and supportedInterfaceOrientations methods to ViewController.m and added window.rootViewController = vc; in "static void iphone_add_screen(UIScreen *screen)" -method under allegroAppDelegate.m. Then i recompiled allegro.

Thank you all for your help.