Page 1 of 1
SDL_Init question
Posted: Wed Feb 24, 2010 8:12 pm
by jacob.krustchinsky
I have been using the most widely taught SDL_Init( SDL_INIT_EVERYTHING ); in my code for the past few weeks and I just have a simple question. I have a tendency to be a speed freak and try to suck as much performance out of an application as possible. So my question is... would the SDL application run faster if I was to just call the used Sub-system? Or does it not matter whatsoever?
Re: SDL_Init question
Posted: Thu Feb 25, 2010 4:59 am
by Live-Dimension
Just calling the subsystems you use only initialises the systems you want.
Code: Select all
SDL_INIT_TIMER Initializes the timer subsystem.
SDL_INIT_AUDIO Initializes the audio subsystem.
SDL_INIT_VIDEO Initializes the video subsystem.
SDL_INIT_CDROM Initializes the cdrom subsystem.
SDL_INIT_JOYSTICK Initializes the joystick subsystem.
SDL_INIT_EVERYTHING Initialize all of the above.
SDL_INIT_NOPARACHUTE Prevents SDL from catching fatal signals.
SDL_INIT_EVENTTHREAD
So you'd go something like this
int SDL_init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO);
Since your game may not use a joystick, and almost certainly not use a CD-rom, SDL doesn't have to spend time initialising them saving memory and possible bugs/crashes later on. Mid-game would it make a difference? Barely noticeable if at all.