how to run different oF apps on different displays (from same PC)

Let’s say I have two oF apps, each of them running fullscreen. I want to run them from the same PC which is attached to two displays. How can I get one app running on display 1 and the other on display 2?

I have tried toggling the fullscreen mode with ofToggleFullscreen(), moving one out of fullscreen, moving it to the desired display, and toggling it back into fullscreen mode, but that pops it back into the other display.

I have tried moving where it lives using ofSetWindowPosition() but that seems to only affect it when it isn’t in fullscreen mode.

I’ve read that it’s possible to get them running “fullscreen” by removing the borders, but that there’s a performance hit for doing so (instead of the real fullscreen mode), which I can’t tolerate for this particular app.

Any suggestions on how to make this work?


maybe this just isn’t possible?

I thought I had searched through and found everything worth trying in the archives (with no success), but yet another search turned up an old gem from zach that seems to do the trick:

if (!showWindowBorder){  
		HWND m_hWnd = WindowFromDC(wglGetCurrentDC());  
		LONG style = ::GetWindowLong(m_hWnd, GWL_STYLE);  
		style &= ~WS_DLGFRAME;  
		style &= ~WS_CAPTION;  
		style &= ~WS_BORDER;  
		style &= WS_POPUP;  
		LONG exstyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);  
		exstyle &= ~WS_EX_DLGMODALFRAME;  
		::SetWindowLong(m_hWnd, GWL_STYLE, style);  
		::SetWindowLong(m_hWnd, GWL_EXSTYLE, exstyle);  
		HWND_TOPMOST, 0,0,0,0,  

This is a windows-only fix of course, but that’s fine for me on this particular project.

It creates borderless windows that are also forced to the top so nothing overlays them. I can then push one of the windows onto the 2nd display using ofSetWindowPosition(). Performance seems to be okay (I’ll do more testing and report back if I have any problems).

I had come close to this with other techniques but the Z order thing is what was missing.

1 Like

On mac I do something like this- in the main.cpp i call:

ofSetWindowPosition(1600, 0); // set up screen to second monitor.  

and as long as that X value is greater than the width of screen 1, the app will launch fullscreen on screen2.
However, getScreenWidth() will still return the width of screen 1.
I think this may only work for Macintosh though