mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-08 23:10:58 -04:00
Add sdl mixer lib init/deinit
This commit is contained in:
parent
5c1bf3e6cf
commit
5078b44ec8
@ -27,23 +27,24 @@
|
|||||||
namespace SDL2pp {
|
namespace SDL2pp {
|
||||||
|
|
||||||
SDLMixer::SDLMixer(int flags) {
|
SDLMixer::SDLMixer(int flags) {
|
||||||
if ((IMG_Init(flags) & flags) != flags)
|
if ((Mix_Init(flags) & flags) != flags)
|
||||||
throw Exception("IMG_Init");
|
throw Exception("Mix_Init");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLMixer::~SDLMixer() {
|
SDLMixer::~SDLMixer() {
|
||||||
IMG_Quit();
|
while(Mix_Init(0))
|
||||||
|
Mix_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLMixer::InitMore(int flags) {
|
int SDLMixer::InitMore(int flags) {
|
||||||
int ret;
|
int ret;
|
||||||
if (((ret = IMG_Init(flags)) & flags) != flags)
|
if (((ret = Mix_Init(flags)) & flags) != flags)
|
||||||
throw Exception("IMG_Init");
|
throw Exception("Mix_Init");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLMixer::GetInitFlags() {
|
int SDLMixer::GetInitFlags() {
|
||||||
return IMG_Init(0);
|
return Mix_Init(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,11 @@ namespace SDL2pp {
|
|||||||
///
|
///
|
||||||
/// \headerfile SDL2pp/SDLMixer.hh
|
/// \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:
|
/// Usage example:
|
||||||
/// \code
|
/// \code
|
||||||
/// int main() {
|
/// int main() {
|
||||||
/// SDL2pp::SDL sdl(SDL_INIT_VIDEO);
|
/// SDL2pp::SDL sdl(SDL_INIT_VIDEO);
|
||||||
/// SDL2pp::SDLMixer mixer(IMG_INIT_PNG);
|
/// SDL2pp::SDLMixer mixer(MIX_INIT_OGG);
|
||||||
///
|
|
||||||
/// // use SDL_mixer functions
|
|
||||||
/// SDL2pp::Texture t("/path/to/file.png");
|
|
||||||
///
|
///
|
||||||
/// // SDL_mixer library is automatically deinitialized before exit
|
/// // SDL_mixer library is automatically deinitialized before exit
|
||||||
/// return 0;
|
/// return 0;
|
||||||
@ -57,7 +48,7 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Initializes SDL_mixer library
|
/// \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
|
/// \throws SDL2pp::Exception
|
||||||
///
|
///
|
||||||
@ -77,7 +68,7 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Try to init more SDL_mixer formats
|
/// \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
|
/// \throws SDL2pp::Exception
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user