Make a Non openGL GUI in secondary thread

Is there a way to use a GUI with openframeworks in a separate window that is not a openGL context in Os X 10.10? I ask that because the openframeworks based GUIs are quite heavy.
I’ve tried without succes to use the Qt framework as both Qt and oF need to be in the primary thread.
Anybody knows a diretion to go?
Thanks

you can make OF run in a different thread by creating that thread in main and doing all the initialization from that thread. then you can run qt in the main thread.

at least if you are using the latest version from master or the nightlies not sure about 0.8.4

@arturo what do you mean by doing all the initialization from that thread? Could you post a pseudocode as an example? I’ll post an example of what I’ve tried so far

#include "ofMain.h"
#include "ofApp.h"
#include <thread>
//========================================================================
int main( ){    
    ofGLFWWindowSettings settings;
    settings.windowMode = OF_WINDOW;
    settings.width = 300;
    settings.height = 300;
    settings.setPosition(ofVec2f(300,0));

    shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
    shared_ptr<ofApp> app = make_shared<ofApp>();
    ofRunApp(mainWindow , app);

    thread  t([]{ ofRunMainLoop();});
    
    qtApp.appPointer = app; //pseudocode for passing shared_ptr to qt
    qtApp.exec(); // pseudocode for qt app
    t.join();
}

I don’t have a qt app ready to test (I deleted old attempts) so I’ve included it as pseudo code
this fails with EXC_BAD_ACCESS in the thread t line.

you need to create the opengl context, which is created when you create the window, in that thread too:

    thread  t([]{
        ofGLFWWindowSettings settings;
        settings.windowMode = OF_WINDOW;
        settings.width = 300;
        settings.height = 300;
        settings.setPosition(ofVec2f(300,0));

        auto mainWindow = ofCreateWindow(settings);
        auto app = make_shared<ofApp>();
        ofRunApp(mainWindow , app);

        ofRunMainLoop();
   });

if qt returns immediately then the thread will be destroyed because main will exit, in that case you need to detach the thread so it survives the scope of the function in which it was created:

    thread  t([]{
        ofGLFWWindowSettings settings;
        settings.windowMode = OF_WINDOW;
        settings.width = 300;
        settings.height = 300;
        settings.setPosition(ofVec2f(300,0));

        auto mainWindow = ofCreateWindow(settings);
        auto app = make_shared<ofApp>();
        ofRunApp(mainWindow , app);

        ofRunMainLoop();
   }).detach();

Still got an error with a test code:

int main( ){

    thread t([]{
    ofGLFWWindowSettings settings;
    settings.windowMode = OF_WINDOW;
    settings.width = 300;
    settings.height = 300;
    settings.setPosition(ofVec2f(300,0));

    auto mainWindow = ofCreateWindow(settings);
    auto app = make_shared<ofApp>();
    ofRunApp(mainWindow , app);

        ofRunMainLoop();});
    t.detach();
    while(true){};
}

the error points to

windowP = glfwCreateWindow(settings.width, settings.height, "", NULL, sharedContext);

and outputs

libc++abi.dylib: terminating with uncaught exception of type NSException

it might be that osx has some further restrictions, i’ve tested that in linux even with more than one window running each in one thread and it works without problem

yeah, after doing some research it seems to be a limitation from Cocoa.
Time to change for archlinux maybe, hehe