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

Author Topic: Heavy flickering?  (Read 1717 times)

0 Members and 1 Guest are viewing this topic.

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Heavy flickering?
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Heavy flickering?
« Reply #1 on: December 26, 2011, 04:05:25 pm »
You should draw inside the loop.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Heavy flickering?
« Reply #2 on: December 26, 2011, 04:07:47 pm »
and don't forget to clear the window in between the frames as well.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Heavy flickering?
« Reply #3 on: December 26, 2011, 04:41:44 pm »
Thanks.

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

 

anything