mirror of
https://github.com/yawut/SDL.git
synced 2026-09-09 17:46:31 -05:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user