should get default Cg path...

This commit is contained in:
Themaister 2010-12-29 21:12:56 +01:00
parent 61a70bba6c
commit 423fe969d3
4 changed files with 23 additions and 10 deletions

View File

@ -65,7 +65,6 @@ static const bool video_smooth = true;
// Path to custom Cg shader. If using custom shaders, it is recommended to disable video_smooth.
#ifdef HAVE_CG
extern char cg_shader_path[];
#define DEFAULT_CG_SHADER "hqflt/cg/quad.cg"
#endif

View File

@ -409,8 +409,8 @@ static void* gl_init(video_info_t *video, const input_driver_t **input)
}
cgGLSetOptimalOptions(gl->cgFProf);
cgGLSetOptimalOptions(gl->cgVProf);
gl->cgFPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, cg_shader_path, gl->cgFProf, "main_fragment", 0);
gl->cgVPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, cg_shader_path, gl->cgVProf, "main_vertex", 0);
gl->cgFPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, g_settings.video.cg_shader_path, gl->cgFProf, "main_fragment", 0);
gl->cgVPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, g_settings.video.cg_shader_path, gl->cgVProf, "main_vertex", 0);
if (gl->cgFPrg == NULL || gl->cgVPrg == NULL)
{
CGerror err = cgGetError();

View File

@ -57,7 +57,7 @@ static void set_defaults(void)
g_settings.video.smooth = video_smooth;
g_settings.video.force_aspect = force_aspect;
#if HAVE_CG
strncpy(g_settings.video.cg_shader_path, cg_shader_path, sizeof(g_settings.video.cg_shader_path) - 1);
strncpy(g_settings.video.cg_shader_path, DEFAULT_CG_SHADER, sizeof(g_settings.video.cg_shader_path) - 1);
#endif
strncpy(g_settings.video.video_filter, "foo", sizeof(g_settings.video.video_filter) - 1);
@ -78,6 +78,7 @@ static void set_defaults(void)
g_settings.input.save_state_key = SAVE_STATE_KEY;
g_settings.input.load_state_key = LOAD_STATE_KEY;
g_settings.input.toggle_fullscreen_key = TOGGLE_FULLSCREEN;
g_settings.input.axis_threshold = AXIS_THRESHOLD;
}
void parse_config(void)
@ -149,6 +150,10 @@ void parse_config(void)
free(tmp_str);
}
// Input Settings.
if (config_get_double(conf, "input_axis_threshold", &tmp_double))
g_settings.input.axis_threshold = tmp_double;
// Audio settings.
if (config_get_bool(conf, "audio_enable", &tmp_bool))
g_settings.audio.enable = tmp_bool;
@ -191,6 +196,12 @@ void parse_config(void)
free(tmp_str);
}
if (config_get_string(conf, "video_cg_shader_path", &tmp_str))
{
strncpy(g_settings.video.cg_shader_path, tmp_str, sizeof(g_settings.video.cg_shader_path) - 1);
free(tmp_str);
}
// TODO: Keybinds.
config_file_free(conf);

15
ssnes.c
View File

@ -35,9 +35,6 @@
struct global g_extern = {
.video_active = true,
.audio_active = true,
#if HAVE_CG
.cg_shader_path = DEFAULT_CG_SHADER
#endif
};
// To avoid continous switching if we hold the button down, we require that the button must go from pressed, unpressed back to pressed to be able to toggle between then.
@ -202,6 +199,7 @@ 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");
puts("\t-c/--config: Path for config file. Defaults to $XDG_CONFIG_HOME/ssnes");
#ifdef HAVE_CG
puts("\t-f/--shader: Path to Cg shader. Will be compiled at runtime.\n");
#endif
@ -220,6 +218,7 @@ static void parse_input(int argc, char *argv[])
{ "help", 0, NULL, 'h' },
{ "save", 1, NULL, 's' },
{ "verbose", 0, NULL, 'v' },
{ "config", 0, NULL, 'c' },
#ifdef HAVE_CG
{ "shader", 1, NULL, 'f' },
#endif
@ -228,9 +227,9 @@ static void parse_input(int argc, char *argv[])
int option_index = 0;
#ifdef HAVE_CG
char optstring[] = "hs:vf:";
char optstring[] = "hs:vf:c:";
#else
char optstring[] = "hs:v";
char optstring[] = "hs:vc:";
#endif
for(;;)
{
@ -260,6 +259,10 @@ static void parse_input(int argc, char *argv[])
g_extern.verbose = true;
break;
case 'c':
strncpy(g_extern.config_path, optarg, sizeof(g_extern.config_path) - 1);
break;
case '?':
print_help();
exit(1);
@ -304,8 +307,8 @@ static void parse_input(int argc, char *argv[])
int main(int argc, char *argv[])
{
snes_init();
parse_input(argc, argv);
parse_config();
parse_input(argc, argv);
void *rom_buf;
ssize_t rom_len = 0;