SFML community forums

Help => Graphics => Topic started by: Krofna on December 26, 2011, 03:02:04 pm

Title: Heavy flickering?
Post by: Krofna on December 26, 2011, 03:02:04 pm
Hey.

I got a weird problem with SFML 2.0; The screen is flickering heavily on Windows 7 x86 using Radeon HD 6850 Sapphire, compiled with MS VC++ 2010.
When ran on other computers it works perfectly.

This is very minimum code required to reproduce problem:

Code: [Select]
#include <SFML\Graphics.hpp>

int main()
{
    sf::RenderWindow Window;
    Window.Create(sf::VideoMode(32, 32, 32), "Test Prozor");
    Window.SetFramerateLimit(60);
    sf::Sprite Sprite;
    sf::Texture Texture;
    Texture.LoadFromFile("zeleno.bmp");
    Sprite.SetTexture(Texture);
    Window.Draw(Sprite);

    while (Window.IsOpened())
    {
        sf::Event Event;
        while(Window.PollEvent(Event))
        {
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                return 0;
        }
        Window.Display();
    }
}


Any idea why is this happening?
Title: Heavy flickering?
Post by: Laurent on December 26, 2011, 04:05:25 pm
You should draw inside the loop.
Title: Heavy flickering?
Post by: Groogy on December 26, 2011, 04:07:47 pm
and don't forget to clear the window in between the frames as well.
Title: Heavy flickering?
Post by: Krofna on December 26, 2011, 04:41:44 pm
Thanks.

I can't believe I wrote 500 lines of code not knowing that :oops:  :oops: