OpenFeint + OpenGL - gotchas and sample code?

Discussion in 'Public Game Developers Forum' started by Stroffolino, Jan 15, 2010.

  1. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    Sometimes I wonder if I'm the only one that finds objective C syntax annoying and burdonsome. Most of the apps I've produced are based on the GLUT framework using good old fashioned C/C++ syntax. I rely on ObjectiveC only in places where I must, deep in my porting layer where it doesn't get in the way. I avoid xibs and Delegates and NSStrings like the plague except where I have no choice.

    Is there anyone here that's successfully integrated OpenFeint with an mostly C/C++ OpenGL App, and has a shell project they'd be willing to share? I'd be happy to share source code for one of my older iphone games in return.
     
  2. Mr Jack

    Mr Jack Well-Known Member

    I'm currently integrating OpenFeint into my OpenGL C++ game; it's actually gone pretty smoothly apart from a problem with XCode itself. The OpenFeint stuff itself I hide behind a suitable C++ class, declared .mm style so that I can access OpenFeint from it.

    I won't share source, but I'll happily answer questions.
     
  3. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    Thanks for the offer! I'll see where I get tonight and follow-up with specifics.

    When the last few kinks are sorted out, I'd be happy to donate my OpenGL + iPhone-compatible GLUT framework as sample code for whoever else might find it useful.
     
  4. Mr Jack

    Mr Jack Well-Known Member

    Oh, one thing worth mentioning. You need a UIWindow for OpenFeint to function, swapping the EAGLView class to inherit from UIWindow instead of UIView seems to work for this.
     
  5. mobileben

    mobileben Well-Known Member

    Jul 17, 2009
    595
    0
    0
    Lumpy's Handler
    Zgrunturos and San Francisco
    Our current app and the one we're working on right now is virtually all C++, uses OpenGL and supports OF. The support to OpenGL was pretty straight forward, with nothing really that special to do.

    We launch OF one of two ways. One way we have done it is in the applicationDidFinishLaunching method (of course after our OpenGLView is created). The other way is while the app is already well and running (meaning we've already been displaying screens). I have found that you don't have to define a OpenFeintSettingPresentationWindow in your andSettings array when you call initializeWithProductKey. But if you want to, you'd just pass your root controller's window.

    The only hiccup we did find is really in performance and memory leaks from OF (this is for OF 2.3). Our new app is using OF 2.4, but isn't as large an app as our previous, so we can't be sure if the memory leaks are fixed within OF. Due to performance, we end up turning off music when the dashboard and restart it when the dashboard exits.
     
  6. Mr Jack

    Mr Jack Well-Known Member

    Hey mobileben,

    Have you had trouble with momentary pause when OpenFeint does it stuff? I get a short pause when OpenFeint finishes logging in, even if I suppress the notification. Have you had the same problem? Did you manage to fix it?
     
  7. JamesW

    JamesW Member

    Nov 16, 2009
    10
    0
    0
    My app, KotH, is a hack on the Wolf3D source code, so it started life as a mostly C project. I like Obj-C, so my additions are in Obj-C, but that was pretty irrelevant when it came to integrating OpenFeint. Take a look at the source if you like. The OF stuff is pretty much all in code/iphone/wolf3dAppDelegate.mm.

    Seems to work fine for me with 2.3 and 2.4 even though I left EAGLView's inheritance untouched. Not saying there isn't anything that will bite me, but so far so good!

    I get those. I'm just ignoring it for now. I guess one possibility would be to keep the app at a startup screen until either OF has done it's thing, or you've given up because there's no network.
     
  8. Mr Jack

    Mr Jack Well-Known Member

    That's interesting. Do you specify a window when you call the initialisation or let it find its own?
     
  9. JamesW

    JamesW Member

    Nov 16, 2009
    10
    0
    0
    I don't mention any windows at all, so I guess it must be finding it on its own. My initiailisation code is:
    Code:
      NSDictionary* settings = 
        [NSDictionary dictionaryWithObjectsAndKeys:
          [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft], 
          OpenFeintSettingDashboardOrientation, 
          nil];
    	
      [OpenFeint initializeWithProductKey:JW_OPEN_FEINT_PRODUCT_KEY
        andSecret:JW_OPEN_FEINT_SECRET
        andDisplayName:@"KotH"
        andSettings:settings
        andDelegates:nil];
    	
      [OpenFeint respondToApplicationLaunchOptions:launchOptions];
    
     
  10. Mr Jack

    Mr Jack Well-Known Member

    Yeah, that what it does. For some reason on my game it couldn't locate at window to attach to until I switched UIView for UIWindow.
     
  11. mobileben

    mobileben Well-Known Member

    Jul 17, 2009
    595
    0
    0
    Lumpy's Handler
    Zgrunturos and San Francisco
    We're pretty bare bones on our approach. We used a Windows Based project, and built everything from "scratch". So our OpenGLView inherits from UIView. All we do is add our OpenGLView as a subView of the UIWindow (which is being grabbed from the default nib file).

    Seems to work fine. Although, we seem to have an issue where we cannot show any modal controllers. All our calls to presentModalViewController seem to result in a black screen only. Anyone have any ideas on that slice of bizarreness?

    Sorry for the late reply, I've been focusing on code as of late...

    Well, I'd have to say we just live with it. It is not clear to me just how much you can actually suppress those types of delays. I suspect two issues here. UIKit with OpenGL issues as well as OF code that is clunky. I know on the former, we get delays the first time we invoke the UIKit keyboard. It is possible that even tho you're suppressing the notification, that they are doing some UIKit init behind the scenes.

    Just curious ... when are you initializing OF?

    We've tried both including the window in the settings array and not. They both work. I think your issue may be mainly related to how the window/subview change works. Take that statement with a grain of salt ... I'll always fall back to my I'm a PC/OpenGL guy ;)!
     
  12. Mr Jack

    Mr Jack Well-Known Member

    I traced the code through and I couldn't see any untoward UI initialisation, just a load of response stuff that I figured was causing the delay somewhere in it's deep dark internals.

    But, like you, I don't have much iPhone or Objective-C background - lots of experience doing game development for consoles, only learnt enough Obj-C to get by and done everything else in C++ and OpenGL/AL.

    I was initialising after I finished my load and initialisation but that caused a delay once the game started, so I tried shifting it to as early as possible but that seems to slow the load down so I may have to move it again. Even starting as early as possible the notification still hits at a bad time.
     
  13. mobileben

    mobileben Well-Known Member

    Jul 17, 2009
    595
    0
    0
    Lumpy's Handler
    Zgrunturos and San Francisco
    Hahahaha ... I see you've been forced to step thru OF code as well!

    BTW (changing subjects temporarily), you may want to switch to AudioQueues for your audio. We support both OpenAL and AudioQueues, but you get much more flexibility with AudioQueues and it is pretty straight forward to implement. Our PC version still uses the OpenAL of course.

    You may want to init OF after you do all your loading. That is what we do. Doing it before hand seems to increase loading way more, probably related to how much system you are taxing.

    There is also another method that I've seem some others do, which I've considered. Some people seem to init OF when you hit the OF button to see scores. There is a slight delay in first seeing you're offline. But the beauty of that approach is you know the person is "committed" to seeing OF.
     
  14. Mr Jack

    Mr Jack Well-Known Member


    Just a general FYI on this. I was doing it wrong, and initialising OpenFeint too early. Moving it to applicationDidFinishLaunching solved the need to do that.
     
  15. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    going live

    Ok, so I've got OpenFeint integrated with three of my apps.
    I've used a test user to clear test awards/achievements/leaderboards, and cleaned him back out.

    I'm planning to submit one of these apps to Apple tonight, but what else do I need to do on the OpenFeint side? The apps are all listed as "in development" - there's a "submit" button on the OpenFeint dev portal page, but I'm not sure what it does.
     
  16. You need to press that button! It tells the OpenFeint guys that your app is ready to go live. They will review your app and make sure that everything is setup properly, and then they will mark it as live.

    In my experience it can take anywhere from a few hours to a day or so to get the approval from OpenFeint.

    After your are approved by OF, your social messages to Twitter and Facebook will work (before your app is approved they don't actually get sent out if you are using that feature).
     

Share This Page