#497 USE_VSYNC added to the config (true by default)

This commit is contained in:
BADIM-PC\Vadim 2018-01-11 13:29:44 +03:00
parent ea362a12e0
commit db77e93370
5 changed files with 22 additions and 6 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -66,9 +66,9 @@ static void readConfigNoSound(Config* config, lua_State* lua)
lua_pop(lua, 1); lua_pop(lua, 1);
} }
static void readConfigShowSync(Config* config, lua_State* lua) static void readConfigShowMissedFrames(Config* config, lua_State* lua)
{ {
lua_getglobal(lua, "SYNC_FRAMES"); lua_getglobal(lua, "MISSED_FRAMES");
if(lua_isinteger(lua, -1)) if(lua_isinteger(lua, -1))
config->data.missedFrames = lua_tointeger(lua, -1); config->data.missedFrames = lua_tointeger(lua, -1);
@ -76,6 +76,16 @@ static void readConfigShowSync(Config* config, lua_State* lua)
lua_pop(lua, 1); lua_pop(lua, 1);
} }
static void readConfigUseVsync(Config* config, lua_State* lua)
{
lua_getglobal(lua, "USE_VSYNC");
if(lua_isboolean(lua, -1))
config->data.useVsync = lua_toboolean(lua, -1);
lua_pop(lua, 1);
}
static void readCursorTheme(Config* config, lua_State* lua) static void readCursorTheme(Config* config, lua_State* lua)
{ {
lua_getfield(lua, -1, "CURSOR"); lua_getfield(lua, -1, "CURSOR");
@ -199,7 +209,8 @@ static void readConfig(Config* config)
readConfigVideoScale(config, lua); readConfigVideoScale(config, lua);
readConfigCheckNewVersion(config, lua); readConfigCheckNewVersion(config, lua);
readConfigNoSound(config, lua); readConfigNoSound(config, lua);
readConfigShowSync(config, lua); readConfigShowMissedFrames(config, lua);
readConfigUseVsync(config, lua);
readTheme(config, lua); readTheme(config, lua);
} }

View File

@ -2741,7 +2741,7 @@ static void onFSInitialized(FileSystem* fs)
#if defined(__CHIP__) #if defined(__CHIP__)
SDL_RENDERER_SOFTWARE SDL_RENDERER_SOFTWARE
#else #else
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC SDL_RENDERER_ACCELERATED | (getConfig()->useVsync ? SDL_RENDERER_PRESENTVSYNC : 0)
#endif #endif
); );
@ -2819,7 +2819,11 @@ s32 main(s32 argc, char **argv)
else else
{ {
if(useDelay || SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED) if(useDelay || SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED)
SDL_Delay((u32)(delay * 1000 / SDL_GetPerformanceFrequency())); {
u32 time = (u32)(delay * 1000 / SDL_GetPerformanceFrequency());
if(time >= 10)
SDL_Delay(time);
}
} }
if(studio.missedFrames > 0) if(studio.missedFrames > 0)

View File

@ -101,6 +101,7 @@ typedef struct
bool checkNewVersion; bool checkNewVersion;
bool noSound; bool noSound;
bool useVsync;
s32 missedFrames; s32 missedFrames;
} StudioConfig; } StudioConfig;