Reputation: 20965
is there a way to remove the menu bar items in MAC OSX, when the window was created using glut (glutCreateWindow( "title" );)?
or are there any other alternatives to create (menuless) window for OpenGL in OSX using C/C++ and glut?
Upvotes: 1
Views: 1959
Reputation: 31
glut is creating menu bar items and even keyboard shortcuts on Mac OSX (just try Command+S and you'd be surprised...). There's no easy way to remove these things without accessing Cocoa. The GLUT source code from here shows where all that stuff is being implemented:
http://developer.apple.com/library/mac/#samplecode/glut/Introduction/Intro.html
In order to get rid of the Menus in GLUT, you have to do the following:
add the following code after glutInit():
if (NSApp){
NSMenu *menu;
NSMenuItem *menuItem;
[NSApp setMainMenu:[[NSMenu alloc] init]];
menu = [[NSMenu alloc] initWithTitle:@""];
[menu addItemWithTitle:@"About..." action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" action:nil keyEquivalent:@""];
[menuItem setSubmenu:menu];
[[NSApp mainMenu] addItem:menuItem];
[NSApp setAppleMenu:menu];
}
The code is by Tom de Grunt from here: http://www.degrunt.net/2010/09/22/using-nsmenu-outside-the-nib/
This will set up your application with nothing but an "About..." button within a menu with your Apps name. Just deleting the menu will cause a crash as GLUT expects a menu and has registered a callback for that.
I have search up and down the web for an answer to this and hope that this will help others that ran into the same problem.
Upvotes: 3
Reputation: 1356
Glut has nothing to do with the menu bar. What you could do is to put the application into fullscreen with glutFullscreen() and then define several viewports in your Glut window to simulate your own windows.
Upvotes: 0