forked from Ports/perfect_dark
port: hard cap FPS to 200 for now
This commit is contained in:
1 parent
3a313287bb
commit
7647062619
4 files changed
+22
-7
No files matched your search
@@ -291,7 +291,7 @@ static void gfx_sdl_set_target_fps(int fps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_sdl_can_disable_vsync(void) {
|
static bool gfx_sdl_can_disable_vsync(void) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *gfx_sdl_get_window_handle(void) {
|
static void *gfx_sdl_get_window_handle(void) {
|
||||||
@@ -302,9 +302,13 @@ static void gfx_sdl_set_window_title(const char *title) {
|
|||||||
SDL_SetWindowTitle(wnd, title);
|
SDL_SetWindowTitle(wnd, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_sdl_set_swap_interval(int interval) {
|
static bool gfx_sdl_set_swap_interval(int interval) {
|
||||||
SDL_GL_SetSwapInterval(interval);
|
const bool success = SDL_GL_SetSwapInterval(interval) >= 0;
|
||||||
vsync_enabled = (interval != 0);
|
vsync_enabled = success && (interval != 0);
|
||||||
|
if (!success) {
|
||||||
|
sysLogPrintf(LOG_WARNING, "SDL: failed to set vsync %d: %s", interval, SDL_GetError());
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GfxWindowManagerAPI gfx_sdl = {
|
struct GfxWindowManagerAPI gfx_sdl = {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct GfxWindowManagerAPI {
|
|||||||
bool (*can_disable_vsync)(void);
|
bool (*can_disable_vsync)(void);
|
||||||
void *(*get_window_handle)(void);
|
void *(*get_window_handle)(void);
|
||||||
void (*set_window_title)(const char *);
|
void (*set_window_title)(const char *);
|
||||||
void (*set_swap_interval)(int);
|
bool (*set_swap_interval)(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
#include <PR/ultratypes.h>
|
#include <PR/ultratypes.h>
|
||||||
#include <PR/gbi.h>
|
#include <PR/gbi.h>
|
||||||
|
|
||||||
|
// maximum framerate; if the game runs faster than this, things will break
|
||||||
|
#define VIDEO_MAX_FPS 200
|
||||||
|
|
||||||
s32 videoInit(void);
|
s32 videoInit(void);
|
||||||
void videoStartFrame(void);
|
void videoStartFrame(void);
|
||||||
void videoSubmitCommands(Gfx *cmds);
|
void videoSubmitCommands(Gfx *cmds);
|
||||||
|
|||||||
+10
-2
@@ -46,7 +46,15 @@ s32 videoInit(void)
|
|||||||
|
|
||||||
gfx_init(wmAPI, renderingAPI, "PD", vidFullscreen, vidWidth, vidHeight, 100, 100);
|
gfx_init(wmAPI, renderingAPI, "PD", vidFullscreen, vidWidth, vidHeight, 100, 100);
|
||||||
|
|
||||||
wmAPI->set_swap_interval(vidVsync);
|
if (!wmAPI->set_swap_interval(vidVsync)) {
|
||||||
|
vidVsync = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vidVsync == 0 && vidFramerateLimit == 0) {
|
||||||
|
// cap FPS if there's no vsync to prevent the game from exploding
|
||||||
|
vidFramerateLimit = VIDEO_MAX_FPS;
|
||||||
|
}
|
||||||
|
|
||||||
wmAPI->set_target_fps(vidFramerateLimit); // disabled because vsync is on
|
wmAPI->set_target_fps(vidFramerateLimit); // disabled because vsync is on
|
||||||
renderingAPI->set_texture_filter((enum FilteringMode)texFilter);
|
renderingAPI->set_texture_filter((enum FilteringMode)texFilter);
|
||||||
|
|
||||||
@@ -228,7 +236,7 @@ PD_CONSTRUCTOR static void videoConfigInit(void)
|
|||||||
configRegisterInt("Video.DefaultHeight", &vidHeight, 0, 32767);
|
configRegisterInt("Video.DefaultHeight", &vidHeight, 0, 32767);
|
||||||
configRegisterInt("Video.VSync", &vidVsync, -1, 10);
|
configRegisterInt("Video.VSync", &vidVsync, -1, 10);
|
||||||
configRegisterInt("Video.FramebufferEffects", &vidFramebuffers, 0, 1);
|
configRegisterInt("Video.FramebufferEffects", &vidFramebuffers, 0, 1);
|
||||||
configRegisterInt("Video.FramerateLimit", &vidFramerateLimit, 0, 10000);
|
configRegisterInt("Video.FramerateLimit", &vidFramerateLimit, 0, VIDEO_MAX_FPS);
|
||||||
configRegisterInt("Video.MSAA", &vidMSAA, 1, 16);
|
configRegisterInt("Video.MSAA", &vidMSAA, 1, 16);
|
||||||
configRegisterInt("Video.TextureFilter", &texFilter, 0, 2);
|
configRegisterInt("Video.TextureFilter", &texFilter, 0, 2);
|
||||||
configRegisterInt("Video.TextureFilter2D", &texFilter2D, 0, 1);
|
configRegisterInt("Video.TextureFilter2D", &texFilter2D, 0, 1);
|
||||||
|
|||||||
Reference in new issue
Block a user