SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 19a1e3ec1af52b33ebc468c5f76e833099a57181 parent 1ad8bad18ca02947c351b686179473704cab42e7 Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 8 Jun 2025 20:19:09 +0300 Add a vsync as an option to SDL, fixes #335 Diffstat:
| M | SDL/configuration.h | 3 | +++ |
| M | SDL/gui.c | 35 | +++++++++++++++++++++++++++++++++++ |
| M | SDL/main.c | 2 | ++ |
3 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/SDL/configuration.h b/SDL/configuration.h @@ -161,6 +161,9 @@ typedef struct { /* v1.0.1 */ bool disable_rounded_corners; // Windows only bool use_faux_analog_inputs; + + /* v1.0.2 */ + int8_t vsync_mode; }; } configuration_t; diff --git a/SDL/gui.c b/SDL/gui.c @@ -1598,6 +1598,40 @@ static const char *current_osd_mode(unsigned index) 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 // 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}, {"Display Border:", cycle_border_mode, current_border_mode, cycle_border_mode_backwards}, {"On-Screen Display:", toggle_osd, current_osd_mode, toggle_osd}, + {"Vsync Mode:", cycle_vsync, current_vsync_mode, cycle_vsync_backwards}, #ifdef _WIN32 {"Window Corners:", toggle_corners, current_corner_mode, toggle_corners}, #endif diff --git a/SDL/main.c b/SDL/main.c @@ -1538,6 +1538,8 @@ int main(int argc, char **argv) } #endif + SDL_GL_SetSwapInterval(configuration.vsync_mode); + if (filename == NULL) { stop_on_start = false; run_gui(false);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.