tags:

views:

211

answers:

3

Apologies if this a newbish question, but I'm new to Mac programming, and thought I'd try porting my app to Mac OS.

Basically my question boils down to what are my options and the trade-offs to programming in OpenGL on the Mac?

In doing my own research, I seemingly have come to the conclusion that I have the choice of:

a) Programming against X11 b) Using the Cocoa framework (somehow?)

I'm not sure if there's anything more than those options available.

Anyhow, I'd appreciate knowing what the options are, if there are indeed any, and any trade-offs in doing so. Ideally I'm aiming for the highest levels of portability, so long as I maintain some semblance of performance.

FURTHER INFORMATION:

I've ported my application somewhat thus far, attempting to use X11 as my base (as it currently compiles on Linux). However I'm getting errors with undefined symbols to _glXCreateContext and such, which has me wondering if I'm barking up the wrong tree.

A: 

Depending on what you're trying to do outside of OpenGL, you may have some luck with GLUT (included with Mac OS X) or SDL as the windowing base of your project. I believe SDL uses Cocoa internally on Mac OS X and X11 on Linux.

SDL is pretty portable; it supports all the major platforms. The only downside is that it doesn't have a lot of "application" features like platform-standard open/save dialogue boxes or GUI controls that you would get by writing a Cocoa version of your project.

The same is true for GLUT, but it has a few GUI primitives (right-click menus and buttons) that might be useful.

Targeting X11 directly means that your Mac users have to have the X11 support installed; this is an optional install on many versions of Mac OS X, and you can't necessarily expect them to install it on demand. It also provides a worse user experience by not integrating as well with OS X, in my opinion.

ravuya
A: 

X is a second-class citizen on OS X. It depends on what exactly you want to do with your application, who is going to use it etc., but I’d go with Cocoa (you can start with the Cocoa Drawing Guide). The downside is that Cocoa is quite a world of its own and it will take you some time to get used to it.

zoul
+1  A: 

In addition to the API's mentioned beforehand, there is also AGL/Carbon and Qt.

AGL is somewhat obsolete and will never support 64 Bits.

Qt in imo the best alternative for real applications, since it is cross-platform and provides nice UI support.

eile