Frame limit flag added to config
This commit is contained in:
parent
b5d7dfede9
commit
23fb9d4fd5
2 changed files with 17 additions and 7 deletions
|
@ -19,6 +19,7 @@
|
||||||
// FPS
|
// FPS
|
||||||
#define FRAME_RATE 60
|
#define FRAME_RATE 60
|
||||||
#define FRAME_TIME sf::Time(sf::seconds(1.0f / FRAME_RATE))
|
#define FRAME_TIME sf::Time(sf::seconds(1.0f / FRAME_RATE))
|
||||||
|
#define FRAME_LIMIT_ENABLED false
|
||||||
|
|
||||||
// Window settings
|
// Window settings
|
||||||
#define ANTIALIASINGLEVEL 8
|
#define ANTIALIASINGLEVEL 8
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Game> GameFactory::createWindowed(const std::string &title, int width, int height) {
|
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,
|
auto window = std::make_shared<sf::RenderWindow>(sf::VideoMode(width, height), title,
|
||||||
sf::Style::Default,
|
sf::Style::Default,
|
||||||
getAdditionalSettings());
|
getAdditionalSettings());
|
||||||
|
@ -11,13 +12,16 @@ std::shared_ptr<Game> GameFactory::createWindowed(const std::string &title, int
|
||||||
return Game::constructInstance(window);
|
return Game::constructInstance(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Game> GameFactory::createFullscreen(const std::string &title) {
|
std::shared_ptr<Game> GameFactory::createFullscreen(const std::string &title)
|
||||||
|
{
|
||||||
sf::VideoMode fullScreenMode;
|
sf::VideoMode fullScreenMode;
|
||||||
auto availableModes = sf::VideoMode::getFullscreenModes();
|
auto availableModes = sf::VideoMode::getFullscreenModes();
|
||||||
if (availableModes.empty()) {
|
if (availableModes.empty())
|
||||||
|
{
|
||||||
LOG(INFO) << "No fullscreen modes available, falling back to Desktop Mode.";
|
LOG(INFO) << "No fullscreen modes available, falling back to Desktop Mode.";
|
||||||
fullScreenMode = sf::VideoMode::getDesktopMode();
|
fullScreenMode = sf::VideoMode::getDesktopMode();
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
fullScreenMode = availableModes[0];
|
fullScreenMode = availableModes[0];
|
||||||
fullScreenMode.bitsPerPixel = sf::VideoMode::getDesktopMode().bitsPerPixel;
|
fullScreenMode.bitsPerPixel = sf::VideoMode::getDesktopMode().bitsPerPixel;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +34,8 @@ std::shared_ptr<Game> GameFactory::createFullscreen(const std::string &title) {
|
||||||
return Game::constructInstance(window);
|
return Game::constructInstance(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::ContextSettings GameFactory::getAdditionalSettings() {
|
sf::ContextSettings GameFactory::getAdditionalSettings()
|
||||||
|
{
|
||||||
sf::ContextSettings settings = sf::ContextSettings();
|
sf::ContextSettings settings = sf::ContextSettings();
|
||||||
|
|
||||||
settings.antialiasingLevel = ANTIALIASINGLEVEL;
|
settings.antialiasingLevel = ANTIALIASINGLEVEL;
|
||||||
|
@ -38,7 +43,11 @@ sf::ContextSettings GameFactory::getAdditionalSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameFactory::applyAdditionalWindowConfig(sf::RenderWindow *window) {
|
void GameFactory::applyAdditionalWindowConfig(sf::RenderWindow *window)
|
||||||
// window->setFramerateLimit(FRAME_RATE);
|
{
|
||||||
|
if (FRAME_LIMIT_ENABLED)
|
||||||
|
{
|
||||||
|
window->setFramerateLimit(FRAME_RATE);
|
||||||
|
}
|
||||||
window->setKeyRepeatEnabled(KEY_REPEAT_ENABLED);
|
window->setKeyRepeatEnabled(KEY_REPEAT_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue