mercredi 19 juillet 2017

messed up window content when rendered in thread

So , when I run my program like this, the window that pops up is fine, with a PNG image I attached before:

void Render(Window* w){
    w->render();
}


int main(int argc, char** args){
        <...>
        Render(stock->getWindow(0));
        while(1);
}

But when I run it like this:

int main(int argc, char** args){
        <...>
        std::thread m(Render,stock->getWindow(0));
        m.join();
        while(1);
}

The window pops up, but without the PNG image i had attached. Instead, the window contains the background behind the window (so it shows the application that is physically behind the window, not the PNG image I attach)

Why does the tread mess up my window content?

Aucun commentaire:

Enregistrer un commentaire