Join two windows to the same thread?

Hey guys, I’m trying to figure out how to create two windows and join the two ofRunApp to make the loop sync, I want to play one video in each window in sync.

ofGLFWWindowSettings settings;
settings.width = 800;
settings.height = 800;
settings.resizable = true;
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);

settings.width = 800;
settings.height = 800;
settings.resizable = true;
settings.shareContextWith = mainWindow;
shared_ptr<ofAppBaseWindow> secondW = ofCreateWindow(settings);

shared_ptr<ofApp> mainApp(new ofApp);
shared_ptr<secondWindow> secondApp(new secondWindow);

ofRunApp(mainWindow, mainApp);
ofRunApp(secondW, secondApp);

This has been harder then I thought.

Hi JeanPierreFig,

do you know about “examples/events/multiWindowOneAppExample”?
uncomment the following line in main.cpp:

settings.shareContextWith = mainWindow;	

you will then have the same resources in both contexts (windows).
So in the example if you:

  • load and play video in setup()
  • update video in update()
  • draw video both in draw() and drawGui()

you should be there (just tested it quickly, it works)

have a good day!

Thanks for the reply, but unfortunately the video does not draw on the screen. it does play because one can hear the audio but you do not see anything on neither of windows. I’m creating a ofVideoPlayer object in one window and trying to draw it on another window. I do not know why its not working, did you try it with video?

Hmmm, yes I did try before posting. It worked nicely, showing video on both windows.
As you do not see the video on neither window I assume it is another problem, maybe missing video codec. Does the video work in another OF-App?
If you don’t succeed, I’ll send you a working example, just tell me the system you are using.

I’m on mac 10.12.6

The video will play normally if one does

 void ofSetting::setup(){


void ofSetting::update()


void ofSetting::draw(){

 firstPlayer.draw(0, 0, 720, 1080);


This works

but When I call it from the other window it does not work

settingsWindow->firstPlayer.draw(0, 0, 720, 1080);

If you could send me the test video.

Dear JeanPierreFig,

sorry it took me so long. My mac was not ready. Now it’s working - download the Code here.
Hope it’s useful

have a good day!