Skip to content

Commit

Permalink
add vsync option
Browse files Browse the repository at this point in the history
  • Loading branch information
loganmc10 committed Feb 18, 2022
1 parent 9e1c5f0 commit 9636888
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gfx_m64p.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define KEY_NATIVETEXTLOD "NativeTextLOD"
#define KEY_DEINTERLACE "DeinterlaceMode"
#define KEY_SYNCHRONOUS "SynchronousRDP"
#define KEY_VSYNC "VSync"

#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -148,6 +149,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Co
ConfigOpenSection("Video-Parallel", &configVideoParallel);
ConfigSetDefaultBool(configVideoParallel, KEY_FULLSCREEN, 0, "Use fullscreen mode if True, or windowed mode if False");
ConfigSetDefaultInt(configVideoParallel, KEY_UPSCALING, 1, "Amount of rescaling: 1=None, 2=2x, 4=4x, 8=8x");
ConfigSetDefaultBool(configVideoParallel, KEY_VSYNC, 0, "Enable VSync");
ConfigSetDefaultInt(configVideoParallel, KEY_SCREEN_WIDTH, 640, "Screen width");
ConfigSetDefaultInt(configVideoParallel, KEY_SCREEN_HEIGHT, 480, "Screen height");
ConfigSetDefaultBool(configVideoParallel, KEY_WIDESCREEN, 0, "Widescreen mode (stretched)");
Expand Down Expand Up @@ -246,6 +248,7 @@ EXPORT int CALL RomOpen(void)
window_width = ConfigGetParamInt(configVideoParallel, KEY_SCREEN_WIDTH);
window_height = ConfigGetParamInt(configVideoParallel, KEY_SCREEN_HEIGHT);
window_widescreen = ConfigGetParamBool(configVideoParallel, KEY_WIDESCREEN);
window_vsync = ConfigGetParamBool(configVideoParallel, KEY_VSYNC);
vk_rescaling = ConfigGetParamInt(configVideoParallel, KEY_UPSCALING);
vk_ssreadbacks = ConfigGetParamBool(configVideoParallel, KEY_SSREADBACKS);
vk_ssdither = ConfigGetParamBool(configVideoParallel, KEY_SSDITHER);
Expand Down
8 changes: 8 additions & 0 deletions glguts.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "glguts.h"
#include "gfx_m64p.h"
#include "parallel_imp.h"
#include "m64p_config.h"

#include <string.h>
#include <stdint.h>
Expand All @@ -21,6 +22,7 @@ static ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress = NULL;
static ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute = NULL;
static ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
static ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;
static ptr_ConfigReceiveNetplayConfig ConfigReceiveNetplayConfig = NULL;

static PFNGLCREATESHADERPROC glCreateShader;
static PFNGLSHADERSOURCEPROC glShaderSource;
Expand Down Expand Up @@ -55,6 +57,7 @@ int32_t window_width;
int32_t window_height;
int32_t window_fullscreen;
int32_t window_widescreen;
int32_t window_vsync;

#define SHADER_HEADER "#version 330 core\n"
#define TEX_FORMAT GL_RGBA
Expand Down Expand Up @@ -276,13 +279,18 @@ void screen_init()
CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute)DLSYM(CoreLibHandle, "VidExt_GL_SetAttribute");
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute)DLSYM(CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers)DLSYM(CoreLibHandle, "VidExt_GL_SwapBuffers");
ConfigReceiveNetplayConfig = (ptr_ConfigReceiveNetplayConfig)DLSYM(CoreLibHandle, "ConfigReceiveNetplayConfig");

CoreVideo_Init();

CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE);
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 3);

m64p_error netplay_init = ConfigReceiveNetplayConfig(NULL, 0); // A bit of a hack to determine if netplay is enabled
if (netplay_init == M64ERR_NOT_INIT)
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, window_vsync);

CoreVideo_SetVideoMode(window_width, window_height, 0, window_fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, M64VIDEOFLAG_SUPPORT_RESIZING);

CoreVideo_SetCaption("Mupen64Plus-Parallel");
Expand Down
1 change: 1 addition & 0 deletions glguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern "C"
extern int32_t window_height;
extern int32_t window_fullscreen;
extern int32_t window_widescreen;
extern int32_t window_vsync;

#ifdef __cplusplus
}
Expand Down

0 comments on commit 9636888

Please sign in to comment.