mirror of
https://github.com/haya3218/SDfmL.git
synced 2024-08-14 23:57:09 +00:00
Redo README.md
This commit is contained in:
parent
10bbca486d
commit
7d12a4273e
5 changed files with 25 additions and 69 deletions
|
@ -37,6 +37,7 @@ SoLoud::Soloud Render::music;
|
|||
SoLoud::Soloud Render::se;
|
||||
SoLoud::WavStream Render::waveLoader;
|
||||
SoLoud::Openmpt Render::modLoader;
|
||||
SoLoud::Modplug Render::modPlugLoader;
|
||||
SoLoud::Midi Render::midiLoader;
|
||||
SoLoud::SoundFont Render::current_sf;
|
||||
string Render::currentMusic = "";
|
||||
|
@ -216,10 +217,6 @@ bool Render::Init(string window_name) {
|
|||
});
|
||||
}
|
||||
SOUNDFONT = tomlParse<string>("conf.toml", "config", "soundfont");
|
||||
if (se.init() > 0) {
|
||||
log("SoLoud", " has failed to load. Is your dll broken?", ERROR_, __FILENAME__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
if (music.init() > 0) {
|
||||
log("SoLoud", " has failed to load. Is your dll broken?", ERROR_, __FILENAME__, __LINE__);
|
||||
return false;
|
||||
|
@ -235,7 +232,7 @@ bool Render::Init(string window_name) {
|
|||
return false;
|
||||
}
|
||||
log("SDL_ttf", " has been successfully initialized.", NORMAL, __FILENAME__, __LINE__);
|
||||
window = SDL_CreateWindow(window_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN);
|
||||
window = SDL_CreateWindow(window_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
|
||||
if (window == nullptr) {
|
||||
log("A window", " failed to be created. " + string(SDL_GetError()), ERROR_, __FILENAME__, __LINE__);
|
||||
return false;
|
||||
|
@ -347,9 +344,7 @@ bool Render::Update() {
|
|||
}
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
se.stopAll();
|
||||
music.stopAll();
|
||||
se.deinit();
|
||||
music.deinit();
|
||||
TTF_Quit();
|
||||
SDL_Quit();
|
||||
|
@ -379,10 +374,10 @@ bool Render::playSound(string path, bool override) {
|
|||
log("", "Played sound from " + path, NORMAL, __FILENAME__, __LINE__);
|
||||
waveLoader.setLooping(false);
|
||||
if (override) {
|
||||
se.stop(seIndex);
|
||||
music.stop(seIndex);
|
||||
}
|
||||
waveLoader.load(path.c_str());
|
||||
seIndex = se.play(waveLoader);
|
||||
seIndex = music.play(waveLoader);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -424,9 +419,18 @@ bool Render::playModPlug(string path) {
|
|||
|
||||
return true;
|
||||
}
|
||||
log("", "Played mod tracker from " + path, NORMAL, __FILENAME__, __LINE__);
|
||||
log("", "Try to play " + path + " using libopenmpt", NORMAL, __FILENAME__, __LINE__);
|
||||
if (modLoader.load(path.c_str()) != SoLoud::SO_NO_ERROR) {
|
||||
log("", "Could not play " + path, NORMAL, __FILENAME__, __LINE__);
|
||||
log("", "Playing " + path + " using libmodplug", NORMAL, __FILENAME__, __LINE__);
|
||||
if (modPlugLoader.load(path.c_str()) != SoLoud::SO_NO_ERROR) {
|
||||
log("", "Could not play " + path, NORMAL, __FILENAME__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
modPlugLoader.setLooping(true);
|
||||
music.play(modPlugLoader);
|
||||
currentMusic = path;
|
||||
|
||||
return true;
|
||||
}
|
||||
modLoader.setLooping(true);
|
||||
music.play(modLoader);
|
||||
|
|
|
@ -264,6 +264,7 @@ namespace Render {
|
|||
extern SoLoud::Soloud music;
|
||||
extern SoLoud::WavStream waveLoader;
|
||||
extern SoLoud::Openmpt modLoader;
|
||||
extern SoLoud::Modplug modPlugLoader;
|
||||
extern SoLoud::Midi midiLoader;
|
||||
extern SoLoud::SoundFont current_sf;
|
||||
extern string currentMusic;
|
||||
|
@ -280,6 +281,7 @@ namespace Render {
|
|||
/*
|
||||
* Play music thru the openMPT api (669, amf, ams, dbm, digi, dmf, dsm, far, gdm, ice, imf, it, itp, j2b, m15, mdl, med, mo3, mod, mptm, mt2, mtm, okt, plm, psm, ptm, s3m, stm, ult, umx, wow, xm). Always loops.
|
||||
* When a midi is passed (mid), it will use a TSF-based midi loader instead.
|
||||
* If libopenmpt fails to load, it will resort to the libmodplug api instead.
|
||||
* Passing a blank string (e.g. "") will stop the current playing music.
|
||||
*/
|
||||
bool playModPlug(string path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue