- only enable sRGB if we got an sRGB framebuffer.
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 5 Nov 2017 01:39:08 +0000 (03:39 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 5 Nov 2017 01:39:08 +0000 (03:39 +0200)
- music option

src/app.cc
src/main.cc
src/opt.cc
src/opt.h

index 7f6f077..95f7a05 100644 (file)
@@ -95,11 +95,14 @@ bool app_init(int argc, char **argv)
                goatvr_recenter();
        }
 
                goatvr_recenter();
        }
 
-       int srgb_capable;
-       glGetIntegerv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgb_capable);
-       printf("Framebuffer %s sRGB-capable\n", srgb_capable ? "is" : "is not");
-       fb_srgb = srgb_capable != 0;
-       glEnable(GL_FRAMEBUFFER_SRGB);
+       if(fb_srgb) {
+               int srgb_capable;
+               glGetIntegerv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgb_capable);
+               printf("Framebuffer %s sRGB-capable\n", srgb_capable ? "is" : "is not");
+               if(srgb_capable) {
+                       glEnable(GL_FRAMEBUFFER_SRGB);
+               }
+       }
 
        glEnable(GL_MULTISAMPLE);
        glEnable(GL_DEPTH_TEST);
 
        glEnable(GL_MULTISAMPLE);
        glEnable(GL_DEPTH_TEST);
@@ -169,7 +172,7 @@ bool app_init(int argc, char **argv)
                app_grab_mouse(true);
        }
 
                app_grab_mouse(true);
        }
 
-       if(mscn->music) {
+       if(mscn->music && opt.music) {
                mscn->music->play(AUDIO_PLAYMODE_LOOP);
        }
        return true;
                mscn->music->play(AUDIO_PLAYMODE_LOOP);
        }
        return true;
index 169dbd3..d24428c 100644 (file)
@@ -48,6 +48,7 @@ int main(int argc, char **argv)
        int val;
        SDL_GL_GetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, &val);
        printf("SDL says we %s an sRGB framebuffer\n", val ? "got" : "didn't get");
        int val;
        SDL_GL_GetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, &val);
        printf("SDL says we %s an sRGB framebuffer\n", val ? "got" : "didn't get");
+       fb_srgb = val;
 
        if(!(ctx = SDL_GL_CreateContext(win))) {
                fprintf(stderr, "failed to create OpenGL context\n");
 
        if(!(ctx = SDL_GL_CreateContext(win))) {
                fprintf(stderr, "failed to create OpenGL context\n");
index 18d73f2..f9bcf53 100644 (file)
@@ -10,7 +10,8 @@ Options def_opt = {
        1280, 800,
        false,  // vr
        false,  // fullscreen
        1280, 800,
        false,  // vr
        false,  // fullscreen
-       0               // scene file
+       0,              // scene file
+       true    // music
 };
 
 enum {
 };
 
 enum {
@@ -19,6 +20,7 @@ enum {
        OPT_FULLSCREEN,
        OPT_WINDOWED,
        OPT_SCENEFILE,
        OPT_FULLSCREEN,
        OPT_WINDOWED,
        OPT_SCENEFILE,
+       OPT_MUSIC,
        OPT_HELP
 };
 
        OPT_HELP
 };
 
@@ -29,6 +31,7 @@ static optcfg_option options[] = {
        {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"},
        {'w', "windowed", OPT_WINDOWED, "run in windowed mode"},
        {0, "scene", OPT_SCENEFILE, "scene file to open"},
        {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"},
        {'w', "windowed", OPT_WINDOWED, "run in windowed mode"},
        {0, "scene", OPT_SCENEFILE, "scene file to open"},
+       {'m', "music", OPT_MUSIC, "play background audio"},
        {'h', "help", OPT_HELP, "print usage and exit"},
        OPTCFG_OPTIONS_END
 };
        {'h', "help", OPT_HELP, "print usage and exit"},
        OPTCFG_OPTIONS_END
 };
@@ -95,8 +98,12 @@ static int opt_handler(optcfg *oc, int optid, void *cls)
                opt.scenefile = strdup(optcfg_next_value(oc));
                break;
 
                opt.scenefile = strdup(optcfg_next_value(oc));
                break;
 
+       case OPT_MUSIC:
+               opt.music = is_enabled(oc);
+               break;
+
        case OPT_HELP:
        case OPT_HELP:
-               printf("Usage: vrfileman [options]\nOptions:\n");
+               printf("Usage: demo [options]\nOptions:\n");
                optcfg_print_options(oc);
                exit(0);
        }
                optcfg_print_options(oc);
                exit(0);
        }
index e173545..eb81ceb 100644 (file)
--- a/src/opt.h
+++ b/src/opt.h
@@ -6,6 +6,7 @@ struct Options {
        bool vr;
        bool fullscreen;
        const char *scenefile;
        bool vr;
        bool fullscreen;
        const char *scenefile;
+       bool music;
 };
 
 extern Options opt, def_opt;
 };
 
 extern Options opt, def_opt;