#include <SFML/Config.hpp>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow *render_window;
sf::ContextSettings render_settings;
unsigned char smConsoleActive = 0;
sf::Event evt;
render_settings.AntialiasingLevel = 0;
render_settings.DepthBits = 0;
render_settings.MajorVersion = 2;
render_settings.MinorVersion = 0;
render_settings.StencilBits = 0;
render_window = new sf::RenderWindow(sf::VideoMode(1024,768,32),"win",sf::Style::Titlebar | sf::Style::Close,render_settings);
bool terminate = false;
while(!terminate && render_window->IsOpened())
{
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::F10))
{
std::cout<<"0\n";
smConsoleActive = 0;
}
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::F11))
{
std::cout<<"1\n";
smConsoleActive = 1;
}
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::F12))
{
std::cout<<"2\n";
smConsoleActive = 2;
}
while (render_window->PollEvent(evt))
{
if(evt.Type == sf::Event::TextEntered)
{
switch(evt.Key.Code)
{
case 100 :
// do stuff :
break;
}
}
}
render_window->Clear();
render_window->Display();
}
delete render_window;
return 0;
}
so if you press fast the three F-keys the output in std::cout is wrong ~50% of the time