Cocoa Question

Member
Posts: 509
Joined: 2002.05
Post: #1
I am starting to learn cocoa from the UDG prize book, and I have a few questions.

1. Eventually I want to learn something that can be cross platform, how hard is it to port a Cocoa project to C++ if im using Open GL?

2. Is it as fast as carbon for fullscreen Open GL games? (or close to the same speed)

I will probably post a bunch more questions after I finish the game im working on now and have more time.
Quote this message in a reply
Member
Posts: 204
Joined: 2002.09
Post: #2
Quote:Originally posted by Jake
how hard is it to port a Cocoa project to C++ if im using Open GL?

If you're planning on going cross-platform, I'd suggest attempting to be cross-platform from the start. That means no Cocoa. I believe there are open-source implementation of Obj-C (OpenStep?) but I doubt that you'll have all of the functionality of the Cocoa classes (NSWhatever), which is really one of the strong reasons to use Cocoa in the first place.

Quote:2. Is it as fast as carbon for fullscreen Open GL games? (or close to the same speed)

OpenGL has nothing to do with Cocoa specifically (OpenGL is still a library that your Obj-C compiled application calls), so performance should be exactly the same. Granted, you'll be using different methods to create your OpenGL context and what-not.

Cheers,
Rocco
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #3
Cocoa's method dispatchs are slower than C++ function calls. if you're doing heavy nested looping you might notice a difference. Although realistically you're not going to notice a speed difference; other parts of your program take vastly much more time to execute.

The nice thing about Cocoa is the dynamic typing (hence the slow method dispatch), this aleviates many method type errors and gives you readable exceptions in your console with which to debug your code.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #4
Thanks for the replies. I have one more question, once I learn Cocoa and Obj-C, should learning C++ be easy? Are they similar except different syntax?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
ObjC is nice, C++ isn't.

No, they're not really similar, though they're both based on C so a lot of the syntax will be familiar.
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #6
How easy it is to port the code depends on how much Cocoa you use, not how much OpenGL. Objective-C can do some things that C++ simply cannot do (or cannot do without a lot of work are restructuring of the program).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
And vice versa, I have to add — there's plenty of stuff which you can do in C++ which doesn't translate nicely to Objective C, though I tend to think it's less important than the stuff that's missing going the other way Smile
Quote this message in a reply
Feanor
Unregistered
 
Post: #8
...and as for the speed issues, you can always find ways to compensate, by violating the dynamism, if you have to. In big loops and other confined spaces, you can call methods just as though they were functions -- of course, if the method you are calling itself calls a lot of methods in the usual way, you might be out of luck. :?:

Most of the setup for OpenGL in Cocoa is trivial. The issue, as mentioned, is partially whether you are using the native interface on OS X (Cocoa, Carbon, whatever). If so, look at another interface for U.I. etc. If you are running full screen, the amount of native code is small. Just isolate it from the OpenGL!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Newbie question: Cocoa and Carbon - which for what and how to get started? BliTz 3 3,199 Jul 27, 2006 10:07 PM
Last Post: OneSadCookie
  Cocoa/Objective-C Question infernooo 2 3,149 Oct 18, 2005 11:26 PM
Last Post: infernooo
  Quick threaded OpenGL drawing question in Cocoa TomorrowPlusX 2 3,865 Nov 11, 2004 05:23 AM
Last Post: TomorrowPlusX
  Cocoa Filename Question Joseph Duchesne 3 3,320 Oct 26, 2003 03:55 PM
Last Post: Joseph Duchesne
  Cocoa: Tile Question Criollo 15 5,975 Oct 3, 2003 02:02 AM
Last Post: Criollo