Cocoa or Carbon GL

Member
Posts: 100
Joined: 2006.05
Post: #1
I'm thinking about diving back into game programming, but I'm at one sticking point. Most OpenGL guides/tutorials are written in Carbon-like C/C++. I was wondering whether or not it will be more advantageous to use Cocoa and Obj-C with OpenGL instead. I'm looking for portability, flexibility, usability, and all that other good stuff. It would also be nice to have a good API. Thanks.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #2
With all the discussion we've been having about this in the last few days, one would think it would be pretty obvious that Cocoa is the way to go.

You have your choice of just how much Obj-C you wish to use in your program. You can choose to use just enough to get the GL context set up and use C (or whatever other language you want) for the rest of the program, or you can use Obj-C for the whole program. It's all up to you. OpenGL is still called via C either way. Using Cocoa as your base system API changes nothing about how OpenGL is used, or it's performance BTW.

[edit] I just noticed that you're also looking for portability. If that is of prime importance to you, then perhaps you should consider using SDL instead. If SDL doesn't interest you, either way, Cocoa is just as portable as Carbon for all intents and purposes. Some say Cocoa is even more portable than Carbon, but I don't think either is portable in any practical sense. [/edit]
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #3
The best way to use OpenGL on the Mac is to write your front end (that means GUI, events and perhaps even OpenGL setup) in Cocoa.

Then write your game related stuff in C or C++ (must use ObjC++ if you plan to use the latter, ie your ObjC files must end with .mm instead of .m).

That way you can use your game code as is and just port the front end, which is generally quite small.

I don't think it's a good idea to use Carbon, since it won't be 64-bit in 10.5.

"When you dream, there are no rules..."
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #4
I like that last idea. Thanks.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #5
Any opinions on how I should set up OpenGL? I know GLUT is easy, but I'm not sure how 'polished' it would be to make a game with that. Any better alternatives (brute force, SDL, etc.)? I'm looking for something fast and flexible; I probably won't need portability so much here. I suppose this would have to be the part that gets ported between platforms anyway since the gameplay/engine will be straight C or C++... Probably C++...
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
SDL is cross-platform, but won't let you make something very mac-like. Otherwise, you could use <shameless plug>GameShell</shameless plug> or just write it yourself in Cocoa...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa or Carbon? API? sweetandy 5 3,524 Oct 1, 2005 08:20 PM
Last Post: szymczyk