Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL Initialization

Started by GenuineXP Aug 12, 2008 at 1:13 PM 0 replies 750+ views
Original Post
GenuineXP
GenuineXP
Is this safe?
...
SDL_Init(...);
SDL_Init(...);
SDL_Init(...);
SDL_Init(...);
...
// Use SDL here.
...
SDL_Quit();
SDL_Quit();
SDL_Quit();
SDL_Quit();
...
Note that the only place actual SDL calls would be is in between the initialization and shut down calls (where the comment is). I ask this question because I'm not sure how to approach writing plugins for my engine. Several plugins are SDL-based, and I'm curious if each plugin were to initialize SDL and also shut it down when unloaded if things would blow up. (Plugins would not be unloaded until the entire engine is shut down, so one plugin shutting down SDL while other plugins are still using SDL isn't an issue.) I nifty way to sidestep this problem is writing a primer plugin that initializes a library and keeps a reference count, only actually initializing/freeing when appropriate... but I want to avoid this if I can. In either case, I'm wondering if SDL can take this sort of abuse. Thanks!
SiCrane
SiCrane
At least in 1.2.13, it's safe to call SDL_Quit() multiple times, but the first SDL_Quit() call will cleanup the SDL resources.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.