move Ticks initialization tracking to separate function and ensure it's called with SDL_VideoInit is called to init SDL instead of SDL_Init
-- why do we even allow initialization w/o calling at least SDL_Init(0) ?
This commit is contained in:
parent
907ac2687c
commit
33660e58c1
4 changed files with 20 additions and 6 deletions
|
@ -32,9 +32,9 @@
|
|||
|
||||
/* Initialization/Cleanup routines */
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
extern void SDL_StartTicks(void);
|
||||
extern int SDL_TimerInit(void);
|
||||
extern void SDL_TimerQuit(void);
|
||||
extern void SDL_InitTicks(void);
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
extern int SDL_HelperWindowCreate(void);
|
||||
|
@ -43,7 +43,6 @@ extern int SDL_HelperWindowDestroy(void);
|
|||
|
||||
|
||||
/* The initialized subsystems */
|
||||
static Uint32 ticks_started = 0;
|
||||
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
||||
static Uint8 SDL_SubsystemRefCount[ 32 ];
|
||||
|
||||
|
@ -93,10 +92,7 @@ int
|
|||
SDL_InitSubSystem(Uint32 flags)
|
||||
{
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
if (!ticks_started) {
|
||||
SDL_StartTicks();
|
||||
ticks_started = 1;
|
||||
}
|
||||
SDL_InitTicks();
|
||||
#endif
|
||||
|
||||
/* Initialize the timer subsystem */
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
extern void SDL_StartTicks(void);
|
||||
|
||||
/* #define DEBUG_TIMERS */
|
||||
|
||||
typedef struct _SDL_Timer
|
||||
|
@ -70,6 +72,16 @@ typedef struct {
|
|||
|
||||
static SDL_TimerData SDL_timer_data;
|
||||
|
||||
static Uint32 ticks_started = 0;
|
||||
|
||||
void
|
||||
SDL_InitTicks(void)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_StartTicks();
|
||||
ticks_started = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The idea here is that any thread might add a timer, but a single
|
||||
* thread manages the active timer queue, sorted by scheduling time.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define ROUND_RESOLUTION(X) \
|
||||
(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
|
||||
|
||||
extern void SDL_InitTicks(void);
|
||||
extern int SDL_TimerInit(void);
|
||||
extern void SDL_TimerQuit(void);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_rect_c.h"
|
||||
#include "../events/SDL_events_c.h"
|
||||
#include "../timer/SDL_timer_c.h"
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
#include "SDL_opengl.h"
|
||||
|
@ -415,6 +416,10 @@ SDL_VideoInit(const char *driver_name)
|
|||
if (_this != NULL) {
|
||||
SDL_VideoQuit();
|
||||
}
|
||||
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
SDL_InitTicks();
|
||||
#endif
|
||||
|
||||
/* Start the event loop */
|
||||
if (SDL_StartEventLoop() < 0 ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue