-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
very basic and not at a state I'm happy with quite yet
- Loading branch information
1 parent
260bcd1
commit 3649590
Showing
5 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef BONGO_CAT_AUDIO_HPP | ||
#define BONGO_CAT_AUDIO_HPP | ||
#include <global.hpp> | ||
|
||
namespace BongoAudio { | ||
//============================================================================ | ||
// LOAD FROM ... | ||
//============================================================================ | ||
sf::Sound *loadSoundFromFile(const std::string &); | ||
sf::Music *loadMusicFromFile(const std::string &); | ||
//============================================================================ | ||
// BIND TO LUA | ||
//============================================================================ | ||
void bindToLua(); | ||
}; // namespace BongoAudio | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <audio.hpp> | ||
#include <global.hpp> | ||
|
||
//============================================================================ | ||
// LOAD FROM ... | ||
//============================================================================ | ||
sf::Sound *BongoAudio::loadSoundFromFile(const std::string &path) { | ||
sf::SoundBuffer *buffer = new sf::SoundBuffer(); | ||
|
||
if (!buffer->loadFromFile(path)) { | ||
return nullptr; | ||
} | ||
|
||
sf::Sound *sound = new sf::Sound(); | ||
sound->setBuffer(*buffer); | ||
|
||
return sound; | ||
} | ||
|
||
sf::Music *BongoAudio::loadMusicFromFile(const std::string &path) { | ||
sf::Music *music = new sf::Music(); | ||
|
||
if (!music->openFromFile(path)) { | ||
return nullptr; | ||
} | ||
|
||
return music; | ||
} | ||
|
||
//============================================================================ | ||
// BIND TO LUA | ||
//============================================================================ | ||
void BongoAudio::bindToLua() { | ||
luabridge::getGlobalNamespace(LuaState) | ||
.beginNamespace("BongoAudio") | ||
// load functions | ||
.addFunction("loadSoundFromFile", &BongoAudio::loadSoundFromFile) | ||
.addFunction("loadMusicFromFile", &BongoAudio::loadMusicFromFile) | ||
// all things like controlling playback is defined in sfml.hpp | ||
.endNamespace(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters