Advertisement
gravgun

SFML 2.0 RC : Event blocks the app for ~250ms

Oct 20th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <SFML/Window.hpp>
  3.  
  4. using namespace sf;
  5.  
  6. int main(int argc, char** argv[])
  7. {
  8.     RenderWindow window(sf::VideoMode(800, 600), "Event blocking");
  9.     window.setFramerateLimit(60);
  10.    
  11.     Texture bgTex;
  12.     bgTex.loadFromFile("background.png");
  13.    
  14.     RectangleShape bgRect;
  15.     bgRect.setTexture(&bgTex);
  16.     bgRect.setPosition(0, 0);
  17.    
  18.     Event evt;
  19.  
  20.     while (window.isOpen())
  21.     {
  22.         while (window.pollEvent(evt))
  23.         {
  24.             if(evt.type == Event::MouseMoved)
  25.                 bgRect.setSize(Vector2f(Mouse::getPosition().x, Mouse::getPosition().y));
  26.         }
  27.  
  28.         window.clear();
  29.         window.draw(bgRect);
  30.         window.display();
  31.     }
  32.  
  33.     return EXIT_SUCCESS;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement