mirror of https://github.com/LIJI32/SameBoy.git
Add a vsync as an option to SDL, fixes #335
This commit is contained in:
parent
1ad8bad18c
commit
19a1e3ec1a
|
@ -161,6 +161,9 @@ typedef struct {
|
||||||
/* v1.0.1 */
|
/* v1.0.1 */
|
||||||
bool disable_rounded_corners; // Windows only
|
bool disable_rounded_corners; // Windows only
|
||||||
bool use_faux_analog_inputs;
|
bool use_faux_analog_inputs;
|
||||||
|
|
||||||
|
/* v1.0.2 */
|
||||||
|
int8_t vsync_mode;
|
||||||
};
|
};
|
||||||
} configuration_t;
|
} configuration_t;
|
||||||
|
|
||||||
|
|
35
SDL/gui.c
35
SDL/gui.c
|
@ -1598,6 +1598,40 @@ static const char *current_osd_mode(unsigned index)
|
||||||
return configuration.osd? "Enabled" : "Disabled";
|
return configuration.osd? "Enabled" : "Disabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *current_vsync_mode(unsigned index)
|
||||||
|
{
|
||||||
|
switch (configuration.vsync_mode) {
|
||||||
|
default:
|
||||||
|
case 0: return "Disabled";
|
||||||
|
case 1: return "Enabled";
|
||||||
|
case -1: return "Adaptive";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cycle_vsync(unsigned index)
|
||||||
|
{
|
||||||
|
retry:
|
||||||
|
configuration.vsync_mode++;
|
||||||
|
if (configuration.vsync_mode == 2) {
|
||||||
|
configuration.vsync_mode = -1;
|
||||||
|
}
|
||||||
|
if (SDL_GL_SetSwapInterval(configuration.vsync_mode) && configuration.vsync_mode != 0) {
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cycle_vsync_backwards(unsigned index)
|
||||||
|
{
|
||||||
|
retry:
|
||||||
|
configuration.vsync_mode--;
|
||||||
|
if (configuration.vsync_mode == -2) {
|
||||||
|
configuration.vsync_mode = 1;
|
||||||
|
}
|
||||||
|
if (SDL_GL_SetSwapInterval(configuration.vsync_mode) && configuration.vsync_mode != 0) {
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
// Don't use the standard header definitions because we might not have the newest headers
|
// Don't use the standard header definitions because we might not have the newest headers
|
||||||
|
@ -1652,6 +1686,7 @@ static const struct menu_item graphics_menu[] = {
|
||||||
{"Mono Palette:", cycle_palette, current_palette, cycle_palette_backwards},
|
{"Mono Palette:", cycle_palette, current_palette, cycle_palette_backwards},
|
||||||
{"Display Border:", cycle_border_mode, current_border_mode, cycle_border_mode_backwards},
|
{"Display Border:", cycle_border_mode, current_border_mode, cycle_border_mode_backwards},
|
||||||
{"On-Screen Display:", toggle_osd, current_osd_mode, toggle_osd},
|
{"On-Screen Display:", toggle_osd, current_osd_mode, toggle_osd},
|
||||||
|
{"Vsync Mode:", cycle_vsync, current_vsync_mode, cycle_vsync_backwards},
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{"Window Corners:", toggle_corners, current_corner_mode, toggle_corners},
|
{"Window Corners:", toggle_corners, current_corner_mode, toggle_corners},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1538,6 +1538,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_GL_SetSwapInterval(configuration.vsync_mode);
|
||||||
|
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
stop_on_start = false;
|
stop_on_start = false;
|
||||||
run_gui(false);
|
run_gui(false);
|
||||||
|
|
Loading…
Reference in New Issue