mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-07 22:36:49 -04:00
Add sdl mixer lib init/deinit
This commit is contained in:
parent
5c1bf3e6cf
commit
5078b44ec8
@ -27,23 +27,24 @@
|
||||
namespace SDL2pp {
|
||||
|
||||
SDLMixer::SDLMixer(int flags) {
|
||||
if ((IMG_Init(flags) & flags) != flags)
|
||||
throw Exception("IMG_Init");
|
||||
if ((Mix_Init(flags) & flags) != flags)
|
||||
throw Exception("Mix_Init");
|
||||
}
|
||||
|
||||
SDLMixer::~SDLMixer() {
|
||||
IMG_Quit();
|
||||
while(Mix_Init(0))
|
||||
Mix_Quit();
|
||||
}
|
||||
|
||||
int SDLMixer::InitMore(int flags) {
|
||||
int ret;
|
||||
if (((ret = IMG_Init(flags)) & flags) != flags)
|
||||
throw Exception("IMG_Init");
|
||||
if (((ret = Mix_Init(flags)) & flags) != flags)
|
||||
throw Exception("Mix_Init");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SDLMixer::GetInitFlags() {
|
||||
return IMG_Init(0);
|
||||
return Mix_Init(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,20 +31,11 @@ namespace SDL2pp {
|
||||
///
|
||||
/// \headerfile SDL2pp/SDLMixer.hh
|
||||
///
|
||||
/// Though it's possible to use SDL_mixer without initializing it,
|
||||
/// library provides initialization/deinitialization functions to
|
||||
/// be able to preload libraries for specific file format support
|
||||
/// (png, jpeg or tiff) beforehand. In SDL2pp, this is handled by
|
||||
/// this class.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// int main() {
|
||||
/// SDL2pp::SDL sdl(SDL_INIT_VIDEO);
|
||||
/// SDL2pp::SDLMixer mixer(IMG_INIT_PNG);
|
||||
///
|
||||
/// // use SDL_mixer functions
|
||||
/// SDL2pp::Texture t("/path/to/file.png");
|
||||
/// SDL2pp::SDLMixer mixer(MIX_INIT_OGG);
|
||||
///
|
||||
/// // SDL_mixer library is automatically deinitialized before exit
|
||||
/// return 0;
|
||||
@ -57,7 +48,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initializes SDL_mixer library
|
||||
///
|
||||
/// \param[in] flags Flags to pass to IMG_Init()
|
||||
/// \param[in] flags Flags to pass to Mix_Init()
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
@ -77,7 +68,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Try to init more SDL_mixer formats
|
||||
///
|
||||
/// \param[in] flags Flags to pass to IMG_Init()
|
||||
/// \param[in] flags Flags to pass to Mix_Init()
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user