当我关闭SFML窗口或退出时,输入将显示在终端上。
#include <SFML/Graphics.hpp> #include <iostream>int main() {
sf::RenderWindow window(sf::VideoMode(640,480), "SFML", sf::Style::Close | sf::Style::Titlebar | sf::Style::Resize); while(window.isOpen()) { sf::Event event; while(window.pollEvent(event)) { switch(event.type) { case sf::Event::Closed: window.close(); break; case sf::Event::Resized: printf("New window width: %i New window height: %i\n",event.size.width,event.size.height); break; case sf::Event::TextEntered: if(event.text.unicode < 128) { printf("%c", event.text.unicode); } } window.clear(sf::Color::Black); window.display(); } } return 0;}