SDL_Init question

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
jacob.krustchinsky
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Feb 23, 2010 10:18 pm

SDL_Init question

Post 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?
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: SDL_Init question

Post 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.
Image
Post Reply