1
Window / waitEvent - loop.
« on: June 23, 2023, 10:55:14 am »
Is it possible to make simple example, that is something like :
To be done using waitEvent in gameloop instead of pollEvent, and make this basic example work?
#include <iostream>
#include <SFML\Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(300, 300), "SFML Works");
sf::RectangleShape shape(sf::Vector2f(150,150));
shape.setFillColor(sf::Color::Blue);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
#include <SFML\Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(300, 300), "SFML Works");
sf::RectangleShape shape(sf::Vector2f(150,150));
shape.setFillColor(sf::Color::Blue);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
To be done using waitEvent in gameloop instead of pollEvent, and make this basic example work?