X-Git-Url: https://git.cworth.org/git?p=glenv;a=blobdiff_plain;f=glenv.c;h=d5ec2e8735457a7bc80a6fcd7671f875cd23886b;hp=6d27ad4bf402b6d380d619bb9730b50443714c76;hb=HEAD;hpb=455de90fada991ed423c5cd4f20269fc63653d90 diff --git a/glenv.c b/glenv.c index 6d27ad4..d5ec2e8 100644 --- a/glenv.c +++ b/glenv.c @@ -41,10 +41,11 @@ typedef struct options { static void export_options (options_t *options) { - if (options->query) { - glaze_set_first_gl_call_callback ("glenv_query"); - } - + if (options->query) + setenv ("GLENV_QUERY", "1", 1); + else + unsetenv ("GLENV_QUERY"); + if (options->vendor) setenv ("GLENV_GL_VENDOR", options->vendor, 1); else @@ -67,19 +68,19 @@ export_options (options_t *options) unsetenv ("GLENV_GL_SHADING_LANGUAGE_VERSION"); if (options->extensions) - setenv ("GLENV_EXTENSIONS", options->extensions, 1); + setenv ("GLENV_GL_EXTENSIONS", options->extensions, 1); else - unsetenv ("GLENV_EXTENSIONS"); + unsetenv ("GLENV_GL_EXTENSIONS"); if (options->extensions_whitelist) - setenv ("GLENV_EXTENSIONS_WHITELIST", options->extensions_whitelist, 1); + setenv ("GLENV_GL_EXTENSIONS_WHITELIST", options->extensions_whitelist, 1); else - unsetenv ("GLENV_EXTENSIONS_WHITELIST"); + unsetenv ("GLENV_GL_EXTENSIONS_WHITELIST"); if (options->extensions_blacklist) - setenv ("GLENV_EXTENSIONS_BLACKLIST", options->extensions_blacklist, 1); + setenv ("GLENV_GL_EXTENSIONS_BLACKLIST", options->extensions_blacklist, 1); else - unsetenv ("GLENV_EXTENSIONS_BLACKLIST"); + unsetenv ("GLENV_GL_EXTENSIONS_BLACKLIST"); } static void @@ -114,6 +115,14 @@ enum { EXTENSIONS_BLACKLIST_OPT }; +static void +invalid_combination (const char *second, const char *first) +{ + fprintf (stderr, "Error: Option %s cannot be specified after %s\n", + second, first); + exit (1); +} + int main (int argc, char *argv[]) { @@ -172,12 +181,24 @@ main (int argc, char *argv[]) options.shading_language_version = optarg; break; case EXTENSIONS_OPT: + if (options.extensions_whitelist) + invalid_combination ("--extensions", "--extensions-whitelist"); + if (options.extensions_blacklist) + invalid_combination ("--extensions", "--extensions-blacklist"); options.extensions = optarg; break; case EXTENSIONS_WHITELIST_OPT: + if (options.extensions) + invalid_combination ("--extensions-whitelist", "--extensions"); + if (options.extensions_blacklist) + invalid_combination ("--extensions-whitelist", "--extensions-blacklist"); options.extensions_whitelist = optarg; break; case EXTENSIONS_BLACKLIST_OPT: + if (options.extensions) + invalid_combination ("--extensions-blacklist", "--extensions"); + if (options.extensions_whitelist) + invalid_combination ("--extensions-blacklist", "--extensions-whitelist"); options.extensions_blacklist = optarg; break; default: @@ -195,6 +216,8 @@ main (int argc, char *argv[]) export_options (&options); + glaze_set_first_gl_call_callback ("glenv_first_gl_call"); + glaze_execute (argc - optind, &argv[optind], "libglenv.so"); /* If glaze_execute returns then something went wrong. */