From: John Tsiombikas Date: Sat, 29 Sep 2018 03:51:37 +0000 (+0300) Subject: optionally source assets from URL X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=commitdiff_plain;h=3ee6226e6c7110280b4cc05a9c776eed3bfe6555 optionally source assets from URL --- diff --git a/src/app.cc b/src/app.cc index 9f58b5f..4c6559b 100644 --- a/src/app.cc +++ b/src/app.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "app.h" #include "opengl.h" #include "sdr.h" @@ -113,6 +114,11 @@ bool app_init(int argc, char **argv) app_resize(opt.width, opt.height); app_fullscreen(opt.fullscreen); + if(opt.data_url) { + info_log("Adding URL asset source: %s\n", opt.data_url); + ass_add_url("data", opt.data_url); + } + if(opt.vr) { if(goatvr_init() == -1) { return false; diff --git a/src/opt.cc b/src/opt.cc index b5ab7ed..7f3d4bb 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -12,7 +12,8 @@ Options def_opt = { false, // fullscreen 0, // scene file true, // music - true // reflections + true, // reflections + 0 // data url }; enum { @@ -23,6 +24,7 @@ enum { OPT_SCENEFILE, OPT_MUSIC, OPT_REFLECT, + OPT_DATAURL, OPT_HELP }; @@ -35,6 +37,7 @@ static optcfg_option options[] = { {0, "scene", OPT_SCENEFILE, "scene file to open"}, {'m', "music", OPT_MUSIC, "play background audio"}, {'r', "reflect", OPT_REFLECT, "render reflections"}, + {0, "url", OPT_DATAURL, "data URL"}, {'h', "help", OPT_HELP, "print usage and exit"}, OPTCFG_OPTIONS_END }; @@ -109,6 +112,10 @@ static int opt_handler(optcfg *oc, int optid, void *cls) opt.reflect = is_enabled(oc); break; + case OPT_DATAURL: + opt.data_url = strdup(optcfg_next_value(oc)); + break; + case OPT_HELP: printf("Usage: demo [options]\nOptions:\n"); optcfg_print_options(oc); diff --git a/src/opt.h b/src/opt.h index df7ef30..68a87ab 100644 --- a/src/opt.h +++ b/src/opt.h @@ -8,6 +8,7 @@ struct Options { const char *scenefile; bool music; bool reflect; + const char *data_url; }; extern Options opt, def_opt;