OpenGL on Mac OS X

Started by
5 comments, last by CmpDev 13 years, 5 months ago
Hello everyone, I'm currently working on a port of a Windows openGL game to Mac OS X 10.6. The game is written in C++ and mostly it can be compiled on Mac with GCC 4.2 (also compiling it via make and GCC is a requirement, unless a very good reason arises).

However I'm having problems with writing Mac specific code (I'm no Mac expert!). Looking on the net gave me plenty of informations and doubts. The game must be able to switch between windowed and fullscreen mode: what should I use? According to what I found, CGL only supports fullscreen contexts, while AGL is discontinued (seen in a post from 2005).
Cocoa seems to offer a lot of things I don't need with a "scary" VisualBasic-like wrapper for openGL and a visual interface, while Carbon is only there for backwards compatibility. I don't want to add a dependency to X by using GTK or QT so... what should I do? Any clarification or link is welcome!!
[ King_DuckZ out-- ]
Advertisement
Quote:Original post by King_DuckZ
Cocoa seems to offer a lot of things I don't need with a "scary" VisualBasic-like wrapper for openGL and a visual interface, while Carbon is only there for backwards compatibility. I don't want to add a dependency to X by using GTK or QT so... what should I do? Any clarification or link is welcome!!


Use cocoa. You do not need to use the IDE (X Code) to use the API. GCC compiles Objective-C and Objective-C++ just fine (and in fact is what X Code uses under the hood).

All you need to do is establish the rendering context with a single .m (or .mm) file. The rest can be common code.

Stephen M. Webb
Professional Free Software Developer

So, can I just pass ‘pkg-config --libs glu‘ to GCC? With -framework Cocoa? What discouraged me in doing so is that source code from NeHe's lesson 1 for Cocoa seems to hang at startup if compiled this way.
[ King_DuckZ out-- ]
Quote:Original post by King_DuckZ
I don't want to add a dependency to X by using GTK or QT so...

Qt for OS X doesn't rely on X, and uses Cocoa by default. 64-bit support, of course, requires Cocoa.

Quote:Original post by Bregma
GCC compiles Objective-C and Objective-C++ just fine (and in fact is what X Code uses under the hood).

Xcode is moving to LLVM. The Xcode 4 beta uses LLVM by default.
Quote:Original post by King_DuckZ
So, can I just pass ‘pkg-config --libs glu‘ to GCC? With -framework Cocoa?

No, because there are no C++ entry points to Cocoa. You'll still need a minimal amount of Objective-C to set up your window and GL context, but it's incredibly simple.

Quote:Original post by King_DuckZ
What discouraged me in doing so is that source code from NeHe's lesson 1 for Cocoa seems to hang at startup if compiled this way.

NeHe's code is really, really old.
Quote:Original post by Oluseyi
No, because there are no C++ entry points to Cocoa. You'll still need a minimal amount of Objective-C to set up your window and GL context, but it's incredibly simple.

Yup, I meant once Cocoa code is ready. I'll be looking on the net for infos on how to do so, but if you know of any resource... ;)
Quote:Qt for OS X doesn't rely on X, and uses Cocoa by default. 64-bit support, of course, requires Cocoa.

Good to know! I still prefer not to add dependencies to components I don't really need, either way.

So, the way to go is creating a Cocoa window and binding it to a GL context, while unbinding when passing fullscreen, did I get it right?
And ust for my knowledge, what's really deprecated on Mac OS X 10.6?
[ King_DuckZ out-- ]
Quote:Original post by King_DuckZ
I don't want to add a dependency to X by using GTK or QT so... what should I do? Any clarification or link is welcome!!

FYI X11 is installed by default since 10.5 so there is no real dependency when using raw X11.

This topic is closed to new replies.

Advertisement