iDevGames Forums
Menus - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Menus (/thread-6305.html)

Pages: 1 2 3

Menus - DM6 - Aug 24, 2004 03:11 PM

Anyone have a good example on how to hook up some UI elements (specifically menus) to a C++/OpenGL/SDL app? I know Interface Builder is supposed to be easy, as is Cocoa, and I'm not trying to get out of learning them. But a good example project would help me a LOT more than Apple's docs. Many thanks for any help.


Menus - ThemsAllTook - Aug 24, 2004 05:07 PM

The FlipSquare tutorial at is a really good resource for learning Interface Builder. It's how I learned to use it, and I don't see how I could have figured it out otherwise.§ionid=3&id=17&Itemid=27

Alex Diener

Menus - IBethune - Aug 25, 2004 05:45 AM

IB is not going to be much use to you, since you can't use the Cocoa language from within a C++/SDL app. There are some GUI libraries available on that you could take a look at.


- Iain

Menus - aaronsullivan - Aug 25, 2004 07:49 AM

Rolling your own for your exact needs is usually good enough for editing apps (that no one else but your development team will use) or games that have limited menus...

If you are making a final game with menus as your main interface (eww!) you either need to rely heavily on one of the libraries mentioned above or use platform specific code like Cocoa. If you are going mac only, I'd say go Cocoa all the way. Interface builder + Cocoa, etc. will save you days of work. (So I hear. Smile )

Menus - IBethune - Aug 25, 2004 08:23 AM

Yes, but as I said, if you are using SDL with C or C++ then you are 'trapped' within your own C/C++ code. The only route in to modify the interface is to modify the .nib file which has the main menu bar etc. Even editing the SDLMain.m file, which would allow you to forward events from the UI to your C code, there is no route for you to control the UI from your code, for example to show dialog boxes using Cocoa.

At least that's what I've found so far...

- Iain

Menus - aaronsullivan - Aug 25, 2004 08:45 AM

Yes, that's all true. I meant use a library with SDL or abandon SDL if you are going mac only and having a game that uses menus and standard interface elements primarily.

You could probably alter SDL enough to allow tweaking the interface through cocoa and .nibs, but... eventually, you are losing the benefits of SDL's cross platform compiling.

Menus - DM6 - Aug 26, 2004 11:13 AM

Thanks for clearing it up IBethune, I wasn't sure whether it was possible to do it through .nibs and Cocoa with SDL. But the GUI libraries on are too numerous to choose. Let's say it's for an action game that plays in a window, so menus would not be the main interface to the game. I want to keep the menus outside the OpenGL context, in the menubar where they belong. Any advice for which library is best suited to these needs/most reliable? Thanks for your help so far guys.


Menus - aaronsullivan - Aug 26, 2004 12:20 PM

no library compatible with SDL is going to give you access to the standard menu bar. Those GUI libs can only reach the graphics context you set up with SDL. You'd have to use IBethune's method to get access, and like he said, that's for MENU's only. Beyond that it would mean making a lot of Mac OS specific changes to the SDL code... perfectly legal as long as you supply a link to your version of the code with your game... however probably not worth the effort needed. Smile

Menus - DM6 - Aug 26, 2004 09:12 PM

OK, so if I'm fine with restricting myself to menus only, any tips on how to start modifying the .nib file? I'm a C++ programmer and I have no cocoa experience; any tutorials or sample files that could make it clear to me?


Menus - sam - Aug 27, 2004 10:20 AM

With SDL as far as I can tell you change line 15s #define from 0 to 1 (in SDLMain.m)

And make SDLMain.nib

Menus - Kevin Lindeman - Aug 27, 2004 10:20 PM

sam Wrote:With SDL as far as I can tell you change line 15s #define from 0 to 1 (in SDLMain.m)

And make SDLMain.nib

What would you need to put in this nib to make it compatible with the SDLMain.m/h files?

Menus - DM6 - Aug 28, 2004 02:59 PM

Kevin Lindeman Wrote:What would you need to put in this nib to make it compatible with the SDLMain.m/h files?

I'd also very much like to know the answer to this.


Menus - Josh - Aug 28, 2004 05:22 PM

Kevin Lindeman Wrote:What would you need to put in this nib to make it compatible with the SDLMain.m/h files?
I imagine a default Cocoa nib would do the trick. If not, experiment and find out. Smile

Menus - NCarter - Aug 28, 2004 05:30 PM

Look in SDL.framework/Resources: there's a default SDLMain.nib file there. I imagine you can make a copy of it and add your own stuff.

Menus - Diplomtennis - Aug 28, 2004 09:27 PM

My name is Diplomtennis and I don┬ąt have a single clue about Cocoa. Blush

Can someone tell me step-by-step what to do, if I only want to add a simple Command - Q into a SDL Menue?

Or post a link to a good tutorial for Cocoa - dummies maybe?

Or can I do it in Carbon somehow too?