Menus
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.
Duncan
Duncan
The FlipSquare tutorial at CreateMacGames.org 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.
http://www.createmacgames.org/index.php?...&Itemid=27
Alex Diener
http://www.createmacgames.org/index.php?...&Itemid=27
Alex Diener
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 http://www.libsdl.org that you could take a look at.
Cheers
- Iain
Cheers
- Iain
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.
)
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.
)
"Pay no attention to that man behind the curtain." - Wizard of Oz
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
At least that's what I've found so far...
- Iain
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.
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.
"Pay no attention to that man behind the curtain." - Wizard of Oz
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 libsdl.com 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.
Duncan
Duncan
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.
"Pay no attention to that man behind the curtain." - Wizard of Oz
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?
-Duncan
-Duncan
With SDL as far as I can tell you change line 15s #define from 0 to 1 (in SDLMain.m)
And make SDLMain.nib
And make SDLMain.nib
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?
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.
-Duncan
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.
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Does SDL have any support for pull down menus? | WhatMeWorry | 2 | 2,410 |
Nov 6, 2005 01:12 AM Last Post: PowerMacX |
|

