mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-08 06:48:56 -04:00
Add Music ctors from RWops based on undocumented SDL_mixer functions
Fixes #92
This commit is contained in:
parent
e6738b9dad
commit
bb2ff1f066
@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
## 0.14.0 - unreleased
|
||||
### Added
|
||||
* ```Window::GetOpacity()``` and ```Window()::SetOpacity()``` wrappers for functions appeared in SDL 2.0.5
|
||||
* ```Music``` RWops constructors based on undocumented SDL_mixer functions
|
||||
|
||||
### Changed
|
||||
* libSDL2pp now follows SDL2 include path conventions, finding and using SDL2 headers without SDL2/ prefix
|
||||
|
@ -21,8 +21,9 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <SDL2pp/Music.hh>
|
||||
#include <SDL2pp/Exception.hh>
|
||||
#include <SDL2pp/Music.hh>
|
||||
#include <SDL2pp/RWops.hh>
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
@ -35,6 +36,16 @@ Music::Music(const std::string& file) {
|
||||
throw Exception("Mix_LoadMUS");
|
||||
}
|
||||
|
||||
Music::Music(RWops& rwops) {
|
||||
if ((music_ = Mix_LoadMUS_RW(rwops.Get(), 0)) == nullptr)
|
||||
throw Exception("Mix_LoadMUS_RW");
|
||||
}
|
||||
|
||||
Music::Music(RWops& rwops, Mix_MusicType type) {
|
||||
if ((music_ = Mix_LoadMUSType_RW(rwops.Get(), type, 0)) == nullptr)
|
||||
throw Exception("Mix_LoadMUSType_RW");
|
||||
}
|
||||
|
||||
Music::~Music() {
|
||||
if (music_ != nullptr)
|
||||
Mix_FreeMusic(music_);
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
class RWops;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief %Music data
|
||||
///
|
||||
@ -63,6 +65,33 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit Music(const std::string& file);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load music using RWops
|
||||
///
|
||||
/// This uses undocumented SDL_Mixer function. Comment
|
||||
/// in SDL_mixer.h suggests it's only indended to work with
|
||||
/// Ogg and MikMod.
|
||||
///
|
||||
/// \param[in] rwops SDL2pp::RWops used to access music data
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit Music(RWops& rwops);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load music using RWops
|
||||
///
|
||||
/// This uses undocumented SDL_Mixer function.
|
||||
///
|
||||
/// \param[in] rwops SDL2pp::RWops used to access music data
|
||||
/// \param[in] type Music type to load
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Music(RWops& rwops, Mix_MusicType type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Destructor
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user