From f3e19b743c64d0bfa9da9f7e706de1a80eb76d38 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 17 Dec 2017 20:32:44 +1100 Subject: [PATCH] [client] added ability to pass options to renderers --- client/lg-renderer.h | 10 ++++++---- client/main.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/client/lg-renderer.h b/client/lg-renderer.h index d139ffeb..b39e296e 100644 --- a/client/lg-renderer.h +++ b/client/lg-renderer.h @@ -38,10 +38,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA typedef struct LG_RendererParams { - TTF_Font * font; - bool showFPS; - bool resample; - bool vsync; + int argc; + const char ** argv; + TTF_Font * font; + bool showFPS; + bool resample; + bool vsync; } LG_RendererParams; diff --git a/client/main.c b/client/main.c index 5851d3f3..30389901 100644 --- a/client/main.c +++ b/client/main.c @@ -83,6 +83,10 @@ struct AppParams bool scaleMouseInput; bool hideMouse; bool ignoreQuit; + + unsigned int rendererOptSize; + unsigned int rendererOptCount; + const char ** rendererOpts; }; struct AppState state; @@ -716,6 +720,8 @@ int run() } LG_RendererParams lgrParams; + lgrParams.argc = params.rendererOptCount; + lgrParams.argv = params.rendererOpts; lgrParams.font = state.font; lgrParams.resample = params.useMipmap; lgrParams.showFPS = params.showFPS; @@ -936,6 +942,7 @@ void doHelp(char * app) " -m Disable mipmapping\n" " -v Disable VSYNC\n" " -k Enable FPS display\n" + " -o FLAG Specify a renderer flag\n" "\n" " -a Auto resize the window to the guest\n" " -n Don't allow the window to be manually resized\n" @@ -989,7 +996,7 @@ void doLicense() int main(int argc, char * argv[]) { int c; - while((c = getopt(argc, argv, "hf:sc:p:jMmvkanrdFx:y:w:b:Ql")) != -1) + while((c = getopt(argc, argv, "hf:sc:p:jMmvko:anrdFx:y:w:b:Ql")) != -1) switch(c) { case '?': @@ -1034,6 +1041,17 @@ int main(int argc, char * argv[]) params.showFPS = true; break; + case 'o': + if (params.rendererOptCount == params.rendererOptSize) + { + params.rendererOptSize += 5; + params.rendererOpts = realloc( + params.rendererOpts, + params.rendererOptSize * sizeof(char *)); + } + params.rendererOpts[params.rendererOptCount++] = optarg; + break; + case 'a': params.autoResize = true; break;