Implement SDL2_mixer audio for WASM builds, closes #247
Replace no-op audio stubs in SDL2Types.h with real SDL2_mixer-backed implementations of SoundBuffer, Sound, and Music. This enables audio playback in the browser with zero changes to Python bindings. - Add -sUSE_SDL_MIXER=2 to Emscripten compile/link flags (CMakeLists.txt) - Initialize Mix_OpenAudio in SDL2Renderer::init(), Mix_CloseAudio in shutdown() - SoundBuffer: Mix_LoadWAV/Mix_LoadWAV_RW with duration computation - Sound: channel-based playback with Mix_ChannelFinished tracking - Music: global channel streaming via Mix_LoadMUS/Mix_PlayMusic - Volume conversion: SFML 0-100 scale to SDL_mixer 0-128 scale Known limitations on web: Music.duration and Music.position getters return 0 (SDL_mixer 2.0.2 lacks Mix_MusicDuration/Mix_GetMusicPosition). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ef05152ea0
commit
0969f7c2f6
4 changed files with 290 additions and 29 deletions
|
|
@ -44,6 +44,7 @@ public:
|
|||
void shutdown();
|
||||
bool isInitialized() const { return initialized_; }
|
||||
bool isGLInitialized() const { return glInitialized_; }
|
||||
bool isAudioInitialized() const { return audioInitialized_; }
|
||||
|
||||
// Built-in shader programs
|
||||
enum class ShaderType {
|
||||
|
|
@ -100,6 +101,7 @@ private:
|
|||
|
||||
bool initialized_ = false;
|
||||
bool glInitialized_ = false;
|
||||
bool audioInitialized_ = false;
|
||||
|
||||
// Built-in shader programs
|
||||
unsigned int shapeProgram_ = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue