Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
I'm porting some code over to OS X from Win32 and some other platforms, and it's almost all ported except for functions that create / destroy and OpenGL window - how could I do that in OS X? I started with a foundation app as a sandbox to test my code in but there doesn't seem to be a lot of documentation regarding this specific case. Any help would be appreciated.
 
Drop an OpenGL view onto your window. If you don't know Objective-C and Cocoa, perhaps use the C-based OpenGL Utility Toolkit (GLUT).

For more info about Open GL on Mac OS X, see the OpenGL Programming Guide for Mac OS X.

If you are not using Cocoa then I highly recommend SDL over GLUT. In fact I would recommend cutting your own leg off instead of using GLUT. GLUT has not been updated for many years, has basic functionality at best and is generally rubbish.
 
If you are not using Cocoa then I highly recommend SDL over GLUT. In fact I would recommend cutting your own leg off instead of using GLUT. GLUT has not been updated for many years, has basic functionality at best and is generally rubbish.

I completely agree with this. GLUT cannot easily be abstracted into a class like SDL can. I ran into a HUGE problem in a class I had where we had to write a game engine. I picked OpenGL and GLUT not realizing GLUTs limitations until it was too late.
 
Let me tell you this: as a pro, I'd rather be stabbed than use SDL. Its design is full of hacks (FFS, it #define-s 'main'!), memory allocations at bad times and just plan stupidity.

GLUT isn't bad for prototyping a shader or a render-path quickly but I wouldn't use it for a full-fledged app.

I managed to get something very close to what I like in a sandbox foundation app, and I'll be incorporating this code into my main project in the next few days:

http://paste2.org/p/1480833

Let me know if you have any comments regarding Cocoa abuse I might've accidentally committed in this code.
 
I suggest reading through Driving OpenGL Rendering Loops. Using what Apple suggests will account for about 90% of the "Cocoa abuse" in that code ;)

And capitalized variables is a definite no-no in Cocoa.

Other than that, it's hard to recommend anything without really seeing how you ported the code and structure of your app.
 
Let me tell you this: as a pro, I'd rather be stabbed than use SDL. Its design is full of hacks (FFS, it #define-s 'main'!), memory allocations at bad times and just plan stupidity.

Redefining main is pretty bad but in general it works and has been used in a number of commercial games. I haven't used the new SDL 1.3 yet, let's hope that is better than 1.2.x.
 
Redefining main is pretty bad but in general it works and has been used in a number of commercial games. I haven't used the new SDL 1.3 yet, let's hope that is better than 1.2.x.

I doubt SDL was used in any grown up commercial game except for SDL_Input in some UE 2.x-powered games on non-Win32 PC platforms. Anyone who had to ship on 360 / PS3 would avoid it like the plague.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.