optionally source assets from URL
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 29 Sep 2018 03:51:37 +0000 (06:51 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 29 Sep 2018 03:51:37 +0000 (06:51 +0300)
src/app.cc
src/opt.cc
src/opt.h

index 9f58b5f..4c6559b 100644 (file)
@@ -2,6 +2,7 @@
 #include <limits.h>
 #include <assert.h>
 #include <goatvr.h>
+#include <assman.h>
 #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;
index b5ab7ed..7f3d4bb 100644 (file)
@@ -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);
index df7ef30..68a87ab 100644 (file)
--- 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;