Sharing variables/values between windows

Hi everyone, I’m trying to figure out how to share values between two windows. My intention is to create a GUI on the second one to control settings of the first one. I’m working on 0.9.8. This is the code on my main file.

Thanks!

int main( ){
ofGLFWWindowSettings settings;

settings.width = 300;
settings.height = 300;
settings.setPosition(ofVec2f(0,0));
settings.windowMode = OF_WINDOW;
auto guiWindow = ofCreateWindow(settings);


settings.shareContextWith = guiWindow;
settings.setPosition(ofVec2f(1280, 0));
settings.windowMode = OF_FULLSCREEN;
auto mainWindow = ofCreateWindow(settings);

auto guiApp = make_shared<appGUI>();
auto mainApp = make_shared<app>();

ofRunApp(guiWindow, guiApp);
ofRunApp(mainWindow, mainApp);
ofRunMainLoop();

}

I think this should work, did you try commenting out the lines settings.windowMode ?

also take a look at the multiWindowExample which does exactly what you are looking for

1 Like