diff options
author | chai <chaifix@163.com> | 2018-07-29 13:09:14 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-29 13:09:14 +0800 |
commit | 727fbae9d16f531c47e2462c40d8a5065e4d9909 (patch) | |
tree | 62aee3d3ed5bd90efbe0c931d0046454d14857e6 /test/02Audio/audiotest.cpp | |
parent | b95d0476ce6535c733cb39b784625d67cb25a150 (diff) |
*update
Diffstat (limited to 'test/02Audio/audiotest.cpp')
-rw-r--r-- | test/02Audio/audiotest.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/02Audio/audiotest.cpp b/test/02Audio/audiotest.cpp new file mode 100644 index 0000000..d4b8975 --- /dev/null +++ b/test/02Audio/audiotest.cpp @@ -0,0 +1,70 @@ +#include <iostream> +#include "jin.h" + +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(float dt) +{ + +} + +void onDraw() +{ + +} + +int main(int argc, char* argv[]) +{ + Game* game = Game::get(); + Game::Setting setting; + setting.eventHandler = onEvent; + setting.updater = onUpdate; + setting.drawer = onDraw; + setting.loader = nullptr; + game->init(&setting); + + Window* wnd = Window::get(); + Window::Setting wndSetting; + wndSetting.width = 600; + wndSetting.height = 512; + wndSetting.title = "test"; + wndSetting.fps = 60; + wndSetting.vsync = false; + wndSetting.fullscreen = false; + wndSetting.resizable = false; + wnd->init(&wndSetting); + + SDLAudio* audio = SDLAudio::get(); + SDLAudio::Setting audioSetting; + audioSetting.samplerate = 44100; + audioSetting.samples = 44100; + audio->init(&audioSetting); + + SDLSource* src = SDLSource::createSource("a.ogg"); + src->play(); + src->setLoop(false); + + SDLSource* src2 = SDLSource::createSource("a.wav"); + src2->setLoop(true); + src2->play(); + + audio->setVolume(0.7); + + game->run(); + + game->quit(); + audio->quit(); + wnd->quit(); + + return 0; +}
\ No newline at end of file |