gSurface *gLoadImage(const char *name) { gSurface *ret; SDL_RWops *ops; if(!PHYSFS_exists(name)) { gSetError("gLoadImage was unable to load the image %s", name); return NULL; } ops = PHYSFSRWOPS_openRead(name); if(!ops) { gSetError("gLoadImage was unable to load the image %s: failed _openRead", name); return NULL; } if(!(ret = IMG_Load_RW(ops, true))) { gSetError("gLoadImage was unable to load the image %s: %s", name, SDL_GetError()); return NULL; } return ret; }
void SDLInteraction::playSoundFile(const QString & soundFile) { if (!HWForm::config || !HWForm::config->isFrontendSoundEnabled()) return; SDLAudioInit(); if (!m_audioInitialized) return; if (!m_soundMap->contains(soundFile)) m_soundMap->insert(soundFile, Mix_LoadWAV_RW(PHYSFSRWOPS_openRead(soundFile.toLocal8Bit().constData()), 1)); //FIXME: this is a hack, but works as long as we have few concurrent playing sounds if (Mix_Playing(lastchannel) == false) lastchannel = Mix_PlayChannel(-1, m_soundMap->value(soundFile), 0); }
Mix_Music *music_load_music(cptr file) { Mix_Music *music; SDL_RWops *rops; if (!esettings_get_int("audio.music.enable", 1)) return NULL; rops = PHYSFSRWOPS_openRead(file); if (!rops) { return NULL; } music = Mix_LoadMUS_RW(rops); return music; }
Mix_Chunk *music_load_sample(cptr file) { Mix_Chunk *sample; SDL_RWops *rops; if (!esettings_get_int("audio.effects.enable", 1)) return NULL; rops = PHYSFSRWOPS_openRead(file); if (!rops) { return NULL; } sample = Mix_LoadWAV_RW(rops, TRUE); if (sample) Mix_VolumeChunk(sample, SDL_MIX_MAXVOLUME); return sample; }
void SDLInteraction::startMusic() { if (m_isPlayingMusic) return; m_isPlayingMusic = true; if (m_musicTrack.isEmpty()) return; SDLAudioInit(); if (!m_audioInitialized) return; if (m_music == NULL) m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()), 0); Mix_VolumeMusic(MIX_MAX_VOLUME/4); Mix_FadeInMusic(m_music, -1, 1750); }
SDL_RWops* VFS::GetRWops(const std::string& file) { // Use physfs-rwops to get the file from memory as an sdl_rwops file. return PHYSFSRWOPS_openRead(file.c_str()); }