views:

89

answers:

4

I hope this has a technical (rather than a religious) answer, but I wonder if I should use Objective-C or C++ to create an OpenGL ES Application on the iPad?

As the ultimate goal would be to compile it on Windows and OS X as well, I'm inclined to use C++ (and only use ObjC for the stuff that I have to: App Delegate etc.), but I have zero experience with Objective-C Development.

Can I interact with C++ Classes from Objective-C? Is there any compelling reason to use ObjC over C++?

Or should I just use plain old C?

+1  A: 

You can, it's called Objective-C++ and all you need to do is ensure your source files have a .mm extension for them to be treated as mixed Objective-C/C++ source files.

That said, generally speaking if you're aim is cross platform GLES support, try and write it in C++ for the common things, and anything else, Objective-C (where you need to do things like set up your EAGLLayer etc.). This is likely to work out the best for your purposes, as I presume you're already familiar with C++.

jer
+1  A: 

You need Objective-C to access touches and some other libraries that apple provides. Use .mm to make it Objective-C++ therefore you can use both.

But for portability, use Obj-C only when you need to. Also, what I would like to mention is that OpenGL ES is for Embedded Systems not for Mac OS X or Windows you need to use a OpenGL and yes they are different.

thyrgle
+1  A: 

C++ and Objective-C can intermingle (as Objective-C++), though C++ classes cannot inherit from Objective-C classes, and vice versa. You must also take care to set a compiler flag in Xcode so that your C++ constructors and destructors are called as needed by Objective-C objects.

As to which you should use: either one will work. Objective-C will be necessary for, at least, the user-facing part of the app, as you need it to create a window, OpenGL context, etc. But your logic and engine can be in C++ or even ARM assembly, if needed.

Jonathan Grynspan
+1  A: 

The book iPhone 3D Programming might interest you. The philosophy of the book is to use Objective-C as little as possible. All the rendering code is written in portable C++.

sigjuice