Home Game Development c++ SFML Window in std::thread ignore animation

c++ SFML Window in std::thread ignore animation

0
c++ SFML Window in std::thread ignore animation

[ad_1]

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 is functions from dll, their contents are the same as the functions of the main window

[ad_2]

Previous article The Best Nintendo Switch Black Friday 2023 Deals
Next article Super Mario RPG Sunken Ship password puzzle solution
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!