// // Created by max on 28.04.23. // #include #include "game_factory.hpp" #include "../config.h" std::shared_ptr GameFactory::createWindowed(const std::string &title, int width, int height) { auto window = std::make_shared(sf::VideoMode(width, height), title, sf::Style::Default, getAdditionalSettings()); applyAdditionalWindowConfig(window.get()); return std::make_shared(window); } std::shared_ptr GameFactory::createFullscreen(const std::string &title) { sf::VideoMode fullScreenMode; auto availableModes = sf::VideoMode::getFullscreenModes(); if (availableModes.empty()) { LOG(INFO) << "No fullscreen modes available, falling back to Desktop Mode."; fullScreenMode = sf::VideoMode::getDesktopMode(); } else { fullScreenMode = availableModes[0]; fullScreenMode.bitsPerPixel = sf::VideoMode::getDesktopMode().bitsPerPixel; } auto window = std::make_shared(fullScreenMode, title, sf::Style::Fullscreen, getAdditionalSettings()); applyAdditionalWindowConfig(window.get()); return std::make_shared(window); } sf::ContextSettings GameFactory::getAdditionalSettings() { sf::ContextSettings settings = sf::ContextSettings(); settings.antialiasingLevel = ANTIALIASINGLEVEL; return settings; } void GameFactory::applyAdditionalWindowConfig(sf::RenderWindow *window) { window->setFramerateLimit(FRAME_RATE); window->setKeyRepeatEnabled(KEY_REPEAT_ENABLED); }