Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Gikkman

Pages: [1]
1
System / Ending thread causes fullscreen window to flicker
« on: March 05, 2013, 04:07:53 pm »
Hi.

First of, thanks for a very well made library. It's easy to use, well documented and fast to get used to.

I have however run into a small problem I can't seem to solve by myself:
If I run my application in fullscreen mode and create a secondary thread, the render window will flicker quickly when the thread ends. This does not occur however if I alt-tab to show the console ontop of the render window, or if I choose to run the application in windowed mode.

I'm guessing it has something to do with accessing OpenGL functions in the secondary thread but how can I load OpenGL resources in a background thread without creating the annoying flicker.

Here is some minimal code to recreate the event:

#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>

void threadFunc(){
        sf::Clock clock;
        sf::Time time = sf::seconds(2);

        sf::RenderTexture t;
        while(clock.getElapsedTime().asSeconds() < time.asSeconds() )
        {
        }
}

int main(){
    sf::RenderWindow window(sf::VideoMode(1920,1080), "Test", sf::Style::Fullscreen );
       
        sf::Thread thread(threadFunc); 
        thread.launch();

    while (window.isOpen())
    {
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape) )
                        window.close();

        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::Blue);
        window.display();
    }

    return 0;

}

Hope someone can assist me.

Thanks // Simon (aka. Gikkman)

Pages: [1]