Skip to content

Commit

Permalink
Add vsync option to mupen64plus
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 authored and ata4 committed Jun 4, 2024
1 parent 8a1cc86 commit bee938c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/plugin/mupen64plus/gfx_m64p.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define KEY_VI_WIDESCREEN "ViWidescreen"
#define KEY_VI_HIDE_OVERSCAN "ViHideOverscan"
#define KEY_VI_INTEGER_SCALING "ViIntegerScaling"
#define KEY_VI_VSYNC "ViVsync"

#define KEY_DP_COMPAT "DpCompat"

Expand Down Expand Up @@ -121,6 +122,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Co
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN, config.vi.widescreen, "Use anamorphic 16:9 output mode if True");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN, config.vi.hide_overscan, "Hide overscan area in filteded mode if True");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_INTEGER_SCALING, config.vi.integer_scaling, "Display upscaled pixels as groups of 1x1, 2x2, 3x3, etc. if True");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_VSYNC, config.vi.vsync, "Enable vsync to prevent tearing");
ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_DP_COMPAT, config.dp.compat, "Compatibility mode (0=Fast 1=Moderate 2=Slow");

ConfigSaveSection("Video-General");
Expand Down Expand Up @@ -210,6 +212,7 @@ EXPORT int CALL RomOpen (void)
config.vi.widescreen = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN);
config.vi.hide_overscan = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN);
config.vi.integer_scaling = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_INTEGER_SCALING);
config.vi.vsync = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_VSYNC);

config.dp.compat = ConfigGetParamInt(configVideoAngrylionPlus, KEY_DP_COMPAT);

Expand Down
4 changes: 2 additions & 2 deletions src/plugin/mupen64plus/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ void* IntGetProcAddress(const char *name)

void screen_init(struct n64video_config* config)
{
UNUSED(config);

/* Get the core Video Extension function pointers from the library handle */
CoreVideo_Init = (ptr_VidExt_Init) DLSYM(CoreLibHandle, "VidExt_Init");
CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(CoreLibHandle, "VidExt_Quit");
Expand All @@ -62,6 +60,8 @@ void screen_init(struct n64video_config* config)
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
#endif

CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config->vi.vsync);

CoreVideo_SetVideoMode(win_width, win_height, 0, win_fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, M64VIDEOFLAG_SUPPORT_RESIZING);
}

Expand Down

0 comments on commit bee938c

Please sign in to comment.