Code is best judge. It is real code from my repo. Do you have spoilers?
Window.cpp file
/////////////////////////////////////
#include "Window.hpp"
int main()
{
sf::EventLoop loop;
sf::ContextSettings settings;
settings.depthBits = 24;
settings.majorVersion = 2;
settings.minorVersion = 1;
Window window(sf::VideoMode(800, 600), "SFML window", sf::Style::Default, settings);
Window window2(sf::VideoMode(300, 300), "SFML window with OpenGL", sf::Style::Default, settings);
window2.setVisible(true);
return loop.Run();
}
///////////////////////////////////////////////////
Window.hpp file
//////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
class Window : public sf::Window
{
public:
Window(sf::VideoMode mode, const sf::String& title, sf::Uint32 style, const sf::ContextSettings& settings) :
sf::Window(mode, title, style, settings)
{
useEvents(false);
}
void onKeyPressed() override
{
}
void onResized(int x, int y, int width, int height) override
{
}
void onDraw() override
{
display();
}
void onIdle() override
{
onDraw();
}
};//class MainWindow
I hate switch/case operator. And event loop must be hided as much as possible.My code it is traditional C++ code for any GUI program. sf::Event is redundant entity, each kind of it replaced with approriate virtual handler method.
Switch/case/if noodles hided inside processEvent method of platform dependent class.