diff --git a/config.h b/config.h index d2d1daae31..705b4ecc73 100644 --- a/config.h +++ b/config.h @@ -64,7 +64,10 @@ static const bool vsync = true; static const bool video_smooth = true; // Path to custom Cg shader. If using custom shaders, it is recommended to disable video_smooth. -static const char *cg_shader_path = "hqflt/cg/hq2x.cg"; +#ifdef HAVE_CG +extern char cg_shader_path[]; +#define DEFAULT_CG_SHADER "hqflt/cg/hq2x.cg" +#endif // On resize and fullscreen, rendering area will stay 4:3 static const bool force_aspect = true; diff --git a/ssnes.c b/ssnes.c index a4c001f207..79c33f6825 100644 --- a/ssnes.c +++ b/ssnes.c @@ -346,12 +346,18 @@ static void print_help(void) puts("Usage: ssnes [rom file] [-h/--help | -s/--save]"); puts("\t-h/--help: Show this help message"); puts("\t-s/--save: Path for save file (*.srm). Required when rom is input from stdin"); +#ifdef HAVE_CG + puts("\t-f/--shader: Path to Cg shader. Will be compiled at runtime.\n"); +#endif puts("\t-v/--verbose: Verbose logging"); } static FILE* rom_file = NULL; static char savefile_name_srm[256] = {0}; static bool verbose = false; +#ifdef HAVE_CG +char cg_shader_path[256] = DEFAULT_CG_SHADER; +#endif #define SSNES_LOG(msg, args...) do { \ if (verbose) \ @@ -374,11 +380,18 @@ static void parse_input(int argc, char *argv[]) { "help", 0, NULL, 'h' }, { "save", 1, NULL, 's' }, { "verbose", 0, NULL, 'v' }, +#ifdef HAVE_CG + { "shader", 1, NULL, 'f' }, +#endif { NULL, 0, NULL, 0 } }; int option_index = 0; +#ifdef HAVE_CG + char optstring[] = "hs:vf:"; +#else char optstring[] = "hs:v"; +#endif for(;;) { int c = getopt_long(argc, argv, optstring, opts, &option_index); @@ -397,6 +410,12 @@ static void parse_input(int argc, char *argv[]) savefile_name_srm[sizeof(savefile_name_srm)-1] = '\0'; break; +#ifdef HAVE_CG + case 'f': + strncpy(cg_shader_path, optarg, sizeof(cg_shader_path) - 1); + break; +#endif + case 'v': verbose = true; break;