this is what i approximately do:
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Event.hpp>
class _window
{
public:
void create(std::string windowName, const sf::VideoMode resolution, const bool fullScreen)
{
sf::VideoMode screenSize = sf::VideoMode::getDesktopMode();
_rw.create(resolution, windowName, fullScreen ? 8 : 7);
_rw.setVerticalSyncEnabled(true);
if (!fullScreen)
_rw.setPosition(sf::Vector2i((screenSize.width / 2) - (resolution.width / 2), (screenSize.height / 2) - (resolution.height / 2)));
sf::Mouse::setPosition(sf::Vector2i(_rw.getSize().x / 2, _rw.getSize().y / 2), _rw);
}
sf::RenderWindow& get_rw()
{
return _rw;
}
sf::Event& get_event()
{
return _event;
}
private:
sf::RenderWindow _rw;
sf::Event _event;
};
int main()
{
_window w;
w.create("test", sf::VideoMode(800, 600, 32), false);
while (w.get_rw().isOpen()) {
while (w.get_rw().pollEvent(w.get_event()))
switch (w.get_event().type)
{
case sf::Event::Closed:
w.get_rw().close();
break;
default:
break;
}
w.get_rw().display();
w.get_rw().clear();
}
return 0;
}