This is a total game breaker for me unless I am missing something huge here.
The problem is when I add GetEvent(Event) in my code it slows or even STOPS my program when I move the mouse around.
I display the fps and even added a counter to increment each time the program loops and they both stop dead when I move the mouse.
I have been puzzling over this for quite a while and I cannot find anything on the forum about it.
Here is my code, someone else please run it and see if you get the same results:
#include <SFML/Graphics.hpp>
int main()
{
sf::Font MyFont;
sf::String fps;
sf::String counter;
char buffer[200];
int num = 0;
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");
if (!MyFont.LoadFromFile("font/small/XPAIDERP.TTF", 8))
return EXIT_FAILURE;
fps.SetFont(MyFont);
fps.SetSize(8);
fps.SetPosition(100.f, 100.f);
counter.SetFont(MyFont);
counter.SetSize(8);
counter.SetPosition(100.f, 200.f);
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}
App.Clear();
sprintf( buffer, "FPS = %f", 100.f / App.GetFrameTime() );
fps.SetText( buffer );
App.Draw( fps );
sprintf( buffer, "COUNTER = %d", num );
counter.SetText( buffer );
App.Draw( counter );
App.Display();
num++;
}
return EXIT_SUCCESS;
}
I move the mouse around and both the counter and the fps freeze. This can only mean the program itself is freezing. If I comment out while (App.GetEvent(Event)) then everything goes smoothly and I can move the mouse around with no freezing.
System:
WindowsXP service pack 3
DirectX 9.0c
AMD athlon 2.21 GHZ
2 GB RAM
Using Code::blocks IDE with MingW