OS X openGL hacks

Here is a list of useful hacks for openGL on OS X.

Fullscreen - menu and dock
So there is a mildly annoying bug in the way that GLUT goes fullscreen in OS X. If you click on the screen in your app, near the date&time or login area of the menu bar you will actually see part of the menu appear over your app. This is because when GLUT goes fullscreen it doesn’t actually tell the computer that it is running fullscreen and so the OS still keeps the menu and dock active as if it was a windowed application.

However there is a way to tell the app to hide the menu and dock, with a setting in its preference file. If you look in the list of files in the xcode project the first one should be called. “openFrameworks-info.plist”

Select it and add the line:


Just before the last tag.

This will make your app hide the menu and dock while it is running (both fullscreen and windowed) . Obviously we would like to do this only for when it is running fullscreen so we will try and workout a better solution shortly.

GLUT preferences: Fullscreen across two displays
If you select the openFrameworks menu when the app is running and select preferences, you get the global preferences for GLUT. One of the most useful things this allows you to do is run fullscreen across two monitors.

If you have a second screen already attached which is extending your desktop, select the ‘Extend Desktop’ option in the GLUT preferences. After closing the preferences window don’t hit ‘ESC’ to exit, instead quit the app with Command-Q. If you hit ESC the preferences won’t be saved.

Now when you run a fullscreen app it will run across both monitors at the same time. To change it back just go to the preferences and uncheck ‘Extend Desktop’.

ATI openGL tunning
ATI now has a preferences panel which you can install that allows you to tweak the 3D settings for your graphics card on a per-application basis. It allows you manually set anti aliasing settings and choose between quality vs performance. This software only works if you have a mac with an ATI graphics card (like mine an old powerbook G4).
Download it here : http://ati.amd.com/support/drivers/mac/atidisplays4-5-7.html


Thank you for posting this! I just came across it now and the fullscreen tip is very useful.
Is there a similar easy way to elect the second screen only as fullscreen I wonder?
Great for those ‘demo or die’ moments with projector :slight_smile:

Yeah I am going to look into this more. Unfortunately GLUT is quite conservative on window modes etc - but fullscreen on the second monitor would be dope.

… just checking in. Has fullscreening on the second monitor been figured out by now?

Actually this just works.
Just turn off extended desktop in the GLUT Preferences.
Then move the window to the second display. ( ofSetWindowPosition )
Then make the window app fullscreen ( ofToggleFullscreen )

The app should go fullscreen on the second display.

You could also use ofxFenster (https://github.com/underdoeg/ofxFenster). It contains a helper class called ofxDisplayManager which returns all the available screens on mac and linux.

ofxDisplayManager returns an array with the size and coordinates of all screens. You can use this info to place your window and then call fullscreen. Or you can use the built in function ofxFensterManager::setActiveDisplay to do the same thing.

The following example will create a new window on the second screen and then go fullscreen

        ofxDisplayList displays = ofxDisplayManager::get()->getDisplays();  
	ofxDisplay* disp = displays[0];  
	if(displays.size() > 1)  
		disp = displays[1];  
        ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, winW, 300, OF_WINDOW);  

And this will move your main window to the second screen

  	ofxDisplayList displays = ofxDisplayManager::get()->getDisplays();  
	ofxDisplay* disp = displays[0];  
	if(displays.size() > 1)  
		disp = displays[1];  
	ofSetWindowPosition(disp->x, disp->y);  


Hey hey,

I have recently been trying to get rid of the GLUT menu bar in OSX. Since I haven’t found any advice, I managed to muddle myself through including Cocoa in my GLUT project to access the Menu Bar and replace things. Here’s how that works:
In order to get rid of the Menus in GLUT, you have to do the following:

  1. #include “Cocoa/Cocoa.h” in your main.cpp (or any other file in which you want to call the below function on program startup…).

  2. right-click on that file (in my case main.cpp), select “Get Info”, then in the “General” tab set your “File Type” to sourcecode.cpp.objcpp

  3. include the Cocoa framework in your xcode project

  4. add the following code after ofSetupOpenGL():

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 hope this is useful for some of you!