Jump to content
  • Advertisement
Sign in to follow this  
King_DuckZ

OpenGL OpenGL on Mac OS X

This topic is 2810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!