★ TouchArcade needs your help. Click here to support us on Patreon.

OpenFeint + OpenGL - gotchas and sample code?

01-15-2010, 11:10 AM
#1
Joined: Apr 2009
Location: Pennsylvania
Posts: 1,006
OpenFeint + OpenGL - gotchas and sample code?

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.
01-15-2010, 11:35 AM
#2
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.

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games

01-15-2010, 11:48 AM
#3
Joined: Apr 2009
Location: Pennsylvania
Posts: 1,006
Quote:
Originally Posted by Mr Jack View Post
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.
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.
01-15-2010, 12:27 PM
#4
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.

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games
01-15-2010, 04:51 PM
#5
Joined: Jul 2009
Location: Zgrunturos and San Francisco
Posts: 595
Quote:
Originally Posted by Stroffolino View Post
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.
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.

Go to where the basketball court and arcade go 1 on 1 with Hoops Madness!
01-15-2010, 05:23 PM
#6
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?

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games
01-16-2010, 02:29 PM
#7
Joined: Nov 2009
Posts: 10
Quote:
Originally Posted by Stroffolino View Post
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.
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.

Quote:
Originally Posted by Mr Jack View Post
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.
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!

Quote:
Originally Posted by Mr Jack View Post
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?
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.
01-17-2010, 07:22 AM
#8
Quote:
Originally Posted by JamesW View Post
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!
That's interesting. Do you specify a window when you call the initialisation or let it find its own?

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games
01-18-2010, 01:56 AM
#9
Joined: Nov 2009
Posts: 10
Quote:
Originally Posted by Mr Jack View Post
That's interesting. Do you specify a window when you call the initialisation or let it find its own?
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];
01-18-2010, 05:43 AM
#10
Quote:
Originally Posted by JamesW View Post
I don't mention any windows at all, so I guess it must be finding it on its own.
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.

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games