So I'm just getting back into SFML...This program is meant to display the message as I hold down the backspace button. But it's flickering badly, why is this?
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Window/Event.hpp>
int main()
{
sf::RenderWindow win(sf::VideoMode(500, 500), "Refresher", sf::Style::Default);
sf::Text wb;
sf::Font font;
font.loadFromFile("C:\\Windows\\Fonts\\Arial.ttf");
win.setVerticalSyncEnabled(true);
wb.setColor(sf::Color::Blue);
wb.setString("Welcome Back to SFML!");
wb.setCharacterSize(20);
wb.setStyle(sf::Text::Bold);
wb.setFont(font);
wb.setOrigin(wb.getLocalBounds().width / 2.0f, wb.getLocalBounds().height / 2.0f);
wb.setPosition(win.getSize().x / 2.0f, win.getSize().y / 2.0f);
while (win.isOpen())
{
sf::Event e;
win.clear();
while (win.pollEvent(e))
{
switch (e.type)
{
case sf::Event::Closed:
{
win.close();
}break;
case sf::Event::KeyPressed:
{
switch (e.key.code)
{
case sf::Keyboard::BackSpace:
{
win.draw(wb);
}break;
}
}break;
}
}
win.display();
}
return 0;
}