In my function Game::startDraw(), before draw starts I call window.setActive(true), after that rest of the code is freezed. But, if there is std::cout, freeze is declined. Why??
Working code:
void Game::startDraw() {
window.setActive(true);
std::cout << "Don't freeze!";
while (isOpen()) {
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type) {
case sf::Event::Closed:
setRun(STOP);
window.close();
return;
}
}
window.clear(sf::Color::Blue);
for (auto object : getObjects()) {
window.draw(*object->getSprite());
}
window.display();
}
}
I'm not sure but I think problem is caused by window.setActive().
Window create function:
void Window::createWindow(Game::Game* game, sf::RenderWindow* game_window) {
sf::ContextSettings window_settings;
window_settings.antialiasingLevel = 16;
game_window->create(sf::VideoMode(1920, 1080), *game->getName(), sf::Style::Fullscreen, window_settings);
game_window->setVerticalSyncEnabled(true);
game_window->setActive(false);
}