I am making a game with sfml but have run into a problem. Whenever the program gets to the Window.pollEvent() function it stops until I give the program some kind of event(keyboard press, mouse movement, mouse clicks, ect.). Does anybody know how to make the program keep running even if it isn't receiving an event?
This is my main loop where the problem is:
//SFML libraries
#include <SFML/Graphics.hpp>
//Faster files
#include "globals.h"
#include "ScreenManager.h"
int main()
{
sf::RenderWindow Window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Faster"); //create the window
Window.setFramerateLimit(60); //set the frame limit to 60
ScreenManager::GetInstance().Initialize(); //Initialize the screen manager
ScreenManager::GetInstance().Load(); //load the splash screen from the screen manager
while (Window.isOpen()) //while the window is opened
{
sf::Event Event;
while (Window.pollEvent(Event)) //the game loop
{
if (Event.type == sf::Event::Closed) //if the close button is hit
Window.close(); //close the window
ScreenManager::GetInstance().Update(Window, Event); //update the screen manager
ScreenManager::GetInstance().Draw(Window); //draw the screen
Window.display(); //display the window
Window.clear(); //clear the window
}
}
}