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

Author Topic: Ending thread causes fullscreen window to flicker  (Read 4929 times)

0 Members and 3 Guests are viewing this topic.

Gikkman

  • Newbie
  • *
  • Posts: 3
    • View Profile
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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ending thread causes fullscreen window to flicker
« Reply #1 on: March 05, 2013, 04:14:41 pm »
It's really strange, I'll try to test it at home and see if I can reproduce it.

Does it happen if you don't declare a sf::RenderTexture? If not, does it happen if you declare a sf::Context instead?

What's your OS, graphics card, and revision of SFML 2? Are your graphics drivers up-to-date?
Laurent Gomila - SFML developer

Gikkman

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Ending thread causes fullscreen window to flicker
« Reply #2 on: March 05, 2013, 04:29:51 pm »
Leaving out the sf::RenderTexture removes the flicker.

Declaring a sf::Context creates the flicker.

(Declaring a sf::Texture also creates the flicker).

OS: Windows 7 Enterprise.
Graphics card: nVidia Quadro 2000
Drivers are up to date.

Uses SFML 2.0 RC (downloaded at 13-01-30 from SFML's page)
Using Visual Studio 2010 Ultimate.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Ending thread causes fullscreen window to flicker
« Reply #3 on: March 05, 2013, 04:32:09 pm »
I can't confirm this issue on my Win8 machine with a AMD 7570M graphics card, with uptodate drivers.
But I'm using (nearly) the latest SFML code base.

You might want to try the latest commit (or my nightly build) and see if it's already fixed. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ending thread causes fullscreen window to flicker
« Reply #4 on: March 05, 2013, 04:42:02 pm »
Nothing happened to the code in february, so using the latest sources will most likely do no difference at all.

It's probably a driver specific issue, and I don't know how it could be solved, sorry.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Ending thread causes fullscreen window to flicker
« Reply #5 on: March 05, 2013, 04:56:24 pm »
Nothing happened to the code in february, so using the latest sources will most likely do no difference at all.
Oh I didn't look at the date and only saw SFML 2 RC, which is well a bit older than 13-01-30. ;D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ending thread causes fullscreen window to flicker
« Reply #6 on: March 05, 2013, 05:04:08 pm »
Oh, then I think you're right, it's the RC and the download date is irrelevant. I though it was the revision date ;D
Laurent Gomila - SFML developer

Gikkman

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Ending thread causes fullscreen window to flicker
« Reply #7 on: March 06, 2013, 09:22:08 am »
Tried eXpl0it3r's latest nightly build but that did not remove the flicker.

I tried running my own code on my computer at home (on a gFoce GTX 660) and I did not have the flicker problem. So it is most likely hardware / drivers related.

Thanks for the help :-)