Reputation: 64
I am learning the basics of SFML (enough to make a basic pong game), but I keep getting this strange error with the window. When the window launches sometimes it has a black background (as intented), but about 50% of the time it seems to look like what was behind the window when it launched. I get no errors at compile time.
Here is the bit of the code that I think is causing problems:
//Game loop
while(window.isOpen()){
sf::Event Event;
while(window.pollEvent(Event)){
//Getting input
switch(Event.type){
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
switch(Event.key.code){
case sf::Keyboard::Right:
std::cout << "Right Key Pressed" << std::endl;
break;
case sf::Keyboard::Left:
std::cout << "Left Key Pressed" << std::endl;
break;
case sf::Keyboard::Up:
std::cout << "Up key pressed" << std::endl;
break;
}
break;
}
}
window.display();
}
return 0;
}
This is how I am making my window:
sf::RenderWindow window(sf::VideoMode(screenWidth, screenHeight), "Pong!", sf::Style::Titlebar | sf::Style::Close);
Is there something extreemly obvious I am missing?
Also I am using Linux with xfce4 if that makes any difference.
Upvotes: 0
Views: 200
Reputation: 376
I did not really understand your problem, but did you try to clear the window ?
add "window.clear();" just before "window.display();"
Upvotes: 1