mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 17:17:09 -04:00
Improve vsync setting at startup
Only call it once for OpenGL, avoid causing a pointless context loss for Direct3D9
This commit is contained in:
parent
8749010193
commit
e53f715f29
@ -351,6 +351,7 @@ void Game_Free(void* obj);
|
||||
static void Game_Load(void) {
|
||||
struct IGameComponent* comp;
|
||||
Game_UpdateDimensions();
|
||||
Game_SetFpsLimit(Options_GetEnum(OPT_FPS_LIMIT, 0, FpsLimit_Names, FPS_LIMIT_COUNT));
|
||||
Gfx_Create();
|
||||
Logger_WarnFunc = Game_WarnFunc;
|
||||
LoadOptions();
|
||||
@ -404,10 +405,6 @@ static void Game_Load(void) {
|
||||
TexturePack_ExtractCurrent(false);
|
||||
entTaskI = ScheduledTask_Add(GAME_DEF_TICKS, Entities_Tick);
|
||||
|
||||
/* set vsync after because it causes a context loss depending on backend */
|
||||
Gfx_SetFpsLimit(true, 0);
|
||||
Game_SetFpsLimit(Options_GetEnum(OPT_FPS_LIMIT, 0, FpsLimit_Names, FPS_LIMIT_COUNT));
|
||||
|
||||
if (Gfx_WarnIfNecessary()) EnvRenderer_SetMode(EnvRenderer_Minimal | ENV_LEGACY);
|
||||
Server.BeginConnect();
|
||||
}
|
||||
|
@ -1009,7 +1009,7 @@ void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
if (gfx_vsync == vsync) return;
|
||||
|
||||
gfx_vsync = vsync;
|
||||
Gfx_LoseContext(" (toggling VSync)");
|
||||
if (device) Gfx_LoseContext(" (toggling VSync)");
|
||||
}
|
||||
|
||||
void Gfx_BeginFrame(void) {
|
||||
@ -1143,6 +1143,10 @@ typedef void (*GL_SetupVBRangeFunc)(int startVertex);
|
||||
static GL_SetupVBFunc gfx_setupVBFunc;
|
||||
static GL_SetupVBRangeFunc gfx_setupVBRangeFunc;
|
||||
|
||||
static void GL_UpdateVsync(void) {
|
||||
GLContext_SetFpsLimit(gfx_vsync, gfx_minFrameMs);
|
||||
}
|
||||
|
||||
static void GL_CheckSupport(void);
|
||||
void Gfx_Create(void) {
|
||||
GLContext_Create();
|
||||
@ -1152,6 +1156,7 @@ void Gfx_Create(void) {
|
||||
|
||||
GL_CheckSupport();
|
||||
Gfx_RestoreState();
|
||||
GL_UpdateVsync();
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) {
|
||||
@ -1531,7 +1536,7 @@ void Gfx_GetApiInfo(cc_string* info) {
|
||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
gfx_minFrameMs = minFrameMs;
|
||||
gfx_vsync = vsync;
|
||||
GLContext_SetFpsLimit(vsync, minFrameMs);
|
||||
if (Gfx.Created) GL_UpdateVsync();
|
||||
}
|
||||
|
||||
void Gfx_BeginFrame(void) { frameStart = Stopwatch_Measure(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user