From 8b3ce77b133bbac9979e75a6c88f6b86559d2705 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 5 Nov 2017 03:39:08 +0200 Subject: [PATCH] - only enable sRGB if we got an sRGB framebuffer. - music option --- src/app.cc | 15 +++++++++------ src/main.cc | 1 + src/opt.cc | 11 +++++++++-- src/opt.h | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/app.cc b/src/app.cc index 7f6f077..95f7a05 100644 --- a/src/app.cc +++ b/src/app.cc @@ -95,11 +95,14 @@ bool app_init(int argc, char **argv) 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); @@ -169,7 +172,7 @@ bool app_init(int argc, char **argv) app_grab_mouse(true); } - if(mscn->music) { + if(mscn->music && opt.music) { mscn->music->play(AUDIO_PLAYMODE_LOOP); } return true; diff --git a/src/main.cc b/src/main.cc index 169dbd3..d24428c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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"); + fb_srgb = val; if(!(ctx = SDL_GL_CreateContext(win))) { fprintf(stderr, "failed to create OpenGL context\n"); diff --git a/src/opt.cc b/src/opt.cc index 18d73f2..f9bcf53 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -10,7 +10,8 @@ Options def_opt = { 1280, 800, false, // vr false, // fullscreen - 0 // scene file + 0, // scene file + true // music }; enum { @@ -19,6 +20,7 @@ enum { OPT_FULLSCREEN, OPT_WINDOWED, OPT_SCENEFILE, + OPT_MUSIC, 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"}, + {'m', "music", OPT_MUSIC, "play background audio"}, {'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; + case OPT_MUSIC: + opt.music = is_enabled(oc); + break; + case OPT_HELP: - printf("Usage: vrfileman [options]\nOptions:\n"); + printf("Usage: demo [options]\nOptions:\n"); optcfg_print_options(oc); exit(0); } diff --git a/src/opt.h b/src/opt.h index e173545..eb81ceb 100644 --- a/src/opt.h +++ b/src/opt.h @@ -6,6 +6,7 @@ struct Options { bool vr; bool fullscreen; const char *scenefile; + bool music; }; extern Options opt, def_opt; -- 1.7.10.4