auto init the ticks if the GetTicks and the like methods are called before SDL_Init().. This prevents annoying game bugs such as caching SDL_GetPerformanceFrequency in a static initializer

This commit is contained in:
Edward Rudd
2013-08-17 18:07:29 -04:00
parent 997833aa8a
commit 3f7516d961
6 changed files with 61 additions and 18 deletions

View File

@@ -24,14 +24,24 @@
#include "SDL_timer.h"
static SDL_bool ticks_started = SDL_FALSE;
void
SDL_StartTicks(void)
SDL_InitTicks(void)
{
if (ticks_started) {
return;
}
ticks_started = SDL_TRUE;
}
Uint32
SDL_GetTicks(void)
{
if (!ticks_started) {
SDL_InitTicks();
}
SDL_Unsupported();
return 0;
}