I have a main window whose loop is just in the program and a Window class in which separate sf::RenderWindow
objects are created and the loops for them are in std::thread
, so when adding a button to such a window, the animation is simply ignored, although if you add exactly the same button to the main window, then everything will work fine.
I run this function in the std::thread
:
void Render() {
sf::Event event;
MSG msg = {};
if (prepare_window_function != nullptr) {
prepare_window_function(this);
}
while (Window_ptr->isOpen()) {
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == 160) {
std::ofstream coords("DaTa_hats/_ParamS_/coords");
coords << Window_ptr->getPosition().x << " " << Window_ptr->getPosition().y << std::endl;
coords.close();
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
while (Window_ptr->pollEvent(event)) {
if (event.type == sf::Event::KeyReleased and event.key.code == sf::Keyboard::D) {
Developer_Mode = 1;
}
if (event.type == sf::Event::KeyReleased and event.key.code == sf::Keyboard::Escape) {
Developer_Mode = 0;
}
Handle_Events(event);
}
Window_ptr->clear(sf::Color(100, 100, 100, 255));
if (Is_Rendering) {
Draw_All();
}
Window_ptr->display();
if (Pause_After_Start) {
Pause();
Pause_After_Start = 0;
}
}
}
Handel_Events
and Draw_All
are functions from a DLL, their contents are the same as the functions of the main window