From aa426d13a7fc9d29f4ad46953adb30063dbf250c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 26 Jan 2022 16:00:07 +1100 Subject: [PATCH] [client] egl: added `egl:preset` to load a default preset at startup --- client/renderers/EGL/postprocess.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/client/renderers/EGL/postprocess.c b/client/renderers/EGL/postprocess.c index b1d86d08..5a950677 100644 --- a/client/renderers/EGL/postprocess.c +++ b/client/renderers/EGL/postprocess.c @@ -74,6 +74,12 @@ void egl_postProcessEarlyInit(void) .type = OPTION_TYPE_STRING, .value.x_string = "" }, + { + .module = "egl", + .name = "preset", + .description = "The initial filter preset to load", + .type = OPTION_TYPE_STRING + }, { 0 } }; option_register(options); @@ -82,6 +88,8 @@ void egl_postProcessEarlyInit(void) EGL_Filters[i]->earlyInit(); } +static void loadPreset(struct EGL_PostProcess * this, const char * name); + static void loadPresetList(struct EGL_PostProcess * this) { DIR * dir = NULL; @@ -114,6 +122,8 @@ static void loadPresetList(struct EGL_PostProcess * this) } struct dirent * entry; + const char * preset = option_get_string("egl", "preset"); + bool presetValid = false; while ((entry = readdir(dir)) != NULL) { if (entry->d_type != DT_REG) @@ -127,10 +137,22 @@ static void loadPresetList(struct EGL_PostProcess * this) goto fail; } stringlist_push(this->presets, name); + + if (strcmp(preset, name) == 0) + presetValid = true; } closedir(dir); this->activePreset = -1; + + if (preset) + { + if (presetValid) + loadPreset(this, preset); + else + DEBUG_WARN("egl:preset '%s' does not exist", preset); + } + return; fail: