32 lines
1,003 B
C++
32 lines
1,003 B
C++
|
//
|
||
|
// Created by max on 28.04.23.
|
||
|
//
|
||
|
|
||
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||
|
#include "game_factory.hpp"
|
||
|
|
||
|
|
||
|
std::shared_ptr<Game> GameFactory::createWindowed(const std::string &title, int width, int height)
|
||
|
{
|
||
|
auto window = std::make_shared<sf::RenderWindow>(sf::VideoMode(width, height), title);
|
||
|
return std::make_shared<Game>(window);
|
||
|
}
|
||
|
|
||
|
std::shared_ptr<Game> 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<sf::RenderWindow>(fullScreenMode, title, sf::Style::Fullscreen);
|
||
|
return std::make_shared<Game>(window);
|
||
|
}
|