diff --git a/src/structs.h b/src/structs.h index 6c2dfc9..88368e3 100644 --- a/src/structs.h +++ b/src/structs.h @@ -491,6 +491,7 @@ typedef struct { int fullscreen; int musicVolume; int soundVolume; + int vSync; int doTrophyAlerts; int hideMouse; Gameplay gameplay; diff --git a/src/system/init.c b/src/system/init.c index ed3bd2f..bff80ec 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -61,12 +61,17 @@ void initSDL(void) /* done in src/plat/ */ createSaveFolder(); - - rendererFlags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC; - windowFlags = 0; - + loadConfig(); + rendererFlags = SDL_RENDERER_ACCELERATED; + if (app.vSync) + { + rendererFlags |= SDL_RENDERER_PRESENTVSYNC; + } + + windowFlags = 0; + if (app.fullscreen) { windowFlags |= SDL_WINDOW_FULLSCREEN; @@ -236,6 +241,7 @@ static void loadConfigFile(char *filename) app.fullscreen = cJSON_GetObjectItem(root, "fullscreen")->valueint; app.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint; app.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint; + app.vSync = getJSONValue(root, "vSync", 1); controlsJSON = cJSON_GetObjectItem(root, "controls"); if (controlsJSON) @@ -290,6 +296,7 @@ void saveConfig(void) cJSON_AddNumberToObject(root, "fullscreen", app.fullscreen); cJSON_AddNumberToObject(root, "musicVolume", app.musicVolume); cJSON_AddNumberToObject(root, "soundVolume", app.soundVolume); + cJSON_AddNumberToObject(root, "vSync", app.vSync); keysJSON = cJSON_CreateObject(); for (i = 0 ; i < CONTROL_MAX ; i++) diff --git a/src/system/init.h b/src/system/init.h index b73d321..505fd03 100644 --- a/src/system/init.h +++ b/src/system/init.h @@ -72,6 +72,7 @@ extern long lookup(char *name); extern void initStars(void); extern void initTrophies(void); extern void destroyCredits(void); +extern int getJSONValue(cJSON *node, char *name, int defValue); extern App app; extern Colors colors;