GLUT multi-window solution + bonus


I’ve just pushed my GLUT multi-window solution to my fork.
Here’s what I’ve done:

  • I’ve created an array of ofAppGlutWindow called windows[].

  • All the globals from are now members.

  • Each call to ofSetupOpenGL will add a new window to the array.

  • There’s a new ofSetupOpenGL to create secondary windows.

  • There’s a new ofBaseApp called ofWindowApp.

  • So we can say there’s a pseudo-app for each window.

  • The ofWindowApp has its own setup(), update(), draw(), windowResized() and mouse events.

  • Keyboard callbacks remains on the main window only.

  • The GLUT callbacks are on ofMultiWindow.h/cpp, one for each possible window.

  • Right now OF_MAX_WINDOWS is set to 3. To increase it, we need to implement new static callbacks.

  • This is not very elegant, but solves the problem.

  • Every callback binds it’s window as current by replacing the global window pointer.

  • So each window will see it’s own results for ofGetWidth(), mouseX, etc.


  • Switch focus to main window when App starts (ofAppGlutWindow::runAppViaInfiniteLoop())

  • Remove (ofAppGlutWindow*) casts from ofAppRunner.cpp

  • Test if iPhone remained intact

  • Explore mouse and resize callbacks on apps/examples/multipleWindows

Sample main.cpp:

int main( ){  
    ofAppGlutWindow window;  
	ofSetupOpenGL(&window, 400,200, OF_WINDOW);  
	// Additional windows  
	ofSetupWindow(new windowApp( 0 ), 200,600, OF_WINDOW);  
	// Additional windows  
	ofSetupWindow(new windowApp( 1 ), 500,200, OF_WINDOW);  
	// this kicks off the running of my app  
	ofRunApp( new testApp());  

(everything but ofAppBaseWindow.h)


BONUS 1: ofHideWindowBorders() (unfinished)

I’ve implemented a hack on GLUT for OSX to hide the window borders.
It is disabled by default so it won’t bother anyone with undefined symbols.
I’ve seen solutions for Windows and Linux on the forums, so the entry point is ready for multi-platform support.

But there’s a problem I still have to figure out, it’s not working on the main window… :smiley:

If you want to use it…

If you want my GLUT sources, jus ask and I’ll share it.
It’s based on the distribution from


There’s also a buch of improvements on my fork, here’s a quick list…

  • ofColor revamp based on ofPoint with hex color and HSL support and example)

  • several new functions on ofTypes.h

  • select camera by name, removed scan devices duplicated code

  • select MIDI device by name

  • several primitive alternatives using ofPoint

  • ofImage color key, clone, clone quad and new draw() alternatives

  • ofTexture new draw() alternatives

  • ofShader new setUniform(), setSampler() and apply() for texture FX

  • openCV contour drawing, blob tracker and convexity finder

  • new addon ofxVTK based on The-Visualization-Toolkit with Delaunay2D mesh generator and example, compiled for OSX 10.5. This addon has a LOT of potential, take a look at what VTK can do…

1 Like

wow this all looks amazing! including VTK! I wish I had time to dig in deeper!

I have compiled GLUT so the first window to be created will have its context shared to all following windows.

Here it is (compiled for OSX 10.6):

If it doen’t work, try replacing /Sustem/Lybrary/Frameworks/GLUT.Framework with this one. sometimes even when I ask XCode to link it with the app, it uses the system framework.
But please backup it first.

If anybody need sources, I can provide.

Theo helped me to get rid of that annoying linking problem where the app looks for the System GLUT, not the linked one.
I just uploaded the fixed GLUT.framework and sources to my repo.

Looks like really impressive work :smiley:

Hi Roger!
I’ve been using your GLUT multi window solution on an app of mine. I’m now porting it to the new oF 0.8 and I’m (again) stuck on the problem of xcode linking to the system GLUT. I’ve had this problem a few times but I always managed to fix it. Do you still remember how to do it? I’ve got your code and this works with oF 0.7.3. I just copied my project inside of 0.8.

Thanks for the code and any possible help.