Hello there! After doing research on why the SFML window is paused when you dragged I think I found a decent solution. It works on windows, maybe linux. I don't think it will on mac tho. Anyways I just wanted to see what you guys thought of this code I wrote up.
If you were to use this, I'd recommended creating a thread safe event manager to pass the events on into the other thread.
#include <iostream>
#include <math.h>
#include <SFML/Graphics.hpp>
void GameThread(sf::RenderWindow *window)
{
window->SetFramerateLimit(60);
sf::Image sfmlLogo;
sfmlLogo.LoadFromFile("HaikarainenSFMLLogo.png");
sfmlLogo.SetSmooth(true);
sf::Sprite sprLogo;
sprLogo.SetImage(sfmlLogo);
sprLogo.SetOrigin(floor(sfmlLogo.GetWidth() / 2.f), floor(sfmlLogo.GetHeight() / 2.f));
sprLogo.SetPosition(400,300);
while (window->IsOpened())
{
sprLogo.Rotate(0.5f);
window->Clear();
window->Draw(sprLogo);
window->Display();
}
}
int main()
{
sf::RenderWindow window;
sf::Thread gameThread(&GameThread, &window);
sf::Event event;
window.Create(sf::VideoMode(800,600,32), "Test");
window.SetActive(false);
gameThread.Launch();
while(window.WaitEvent(event))
{
if (event.Type == sf::Event::Closed)
{
window.Close();
}
}
gameThread.Wait();
return EXIT_SUCCESS;
}
Party on,
Preston Alvarado
p.s. I didn't know where to post this to be honest. This forum category seemed good enough.