From 35d0affb2b19a38ae43ac991021dd3c888dc3aa6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 7 Aug 2018 12:56:28 +0800 Subject: *update --- test/02Audio/audiotest.cpp | 70 ------------------------------------- test/02Audio/main.cpp | 70 +++++++++++++++++++++++++++++++++++++ test/03Thread/main.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++ test/03Thread/threadtest.cpp | 83 -------------------------------------------- test/04Network/main.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 236 insertions(+), 153 deletions(-) delete mode 100644 test/02Audio/audiotest.cpp create mode 100644 test/02Audio/main.cpp create mode 100644 test/03Thread/main.cpp delete mode 100644 test/03Thread/threadtest.cpp create mode 100644 test/04Network/main.cpp (limited to 'test') diff --git a/test/02Audio/audiotest.cpp b/test/02Audio/audiotest.cpp deleted file mode 100644 index 4576cfa..0000000 --- a/test/02Audio/audiotest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#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(int ms) -{ - -} - -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 diff --git a/test/02Audio/main.cpp b/test/02Audio/main.cpp new file mode 100644 index 0000000..4576cfa --- /dev/null +++ b/test/02Audio/main.cpp @@ -0,0 +1,70 @@ +#include +#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(int ms) +{ + +} + +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 diff --git a/test/03Thread/main.cpp b/test/03Thread/main.cpp new file mode 100644 index 0000000..a792e53 --- /dev/null +++ b/test/03Thread/main.cpp @@ -0,0 +1,83 @@ +#include +#include +#include "jin.h" + +using namespace std; +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; +using namespace jin::time; +using namespace jin::thread; + +Timers timers; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + timers.update(ms); +} + +void onDraw() +{ + +} + +void thread2Runner(Thread* t) +{ + int i = 0; + while (true) + { + if (i++ == 1000000000) + { + i = 0; + cout << (char*)(t->demand(1).pointer); + } + } +} + +void sendFunc(void* p) +{ + Thread* t = (Thread*)p; + t->send(1, "hello_"); +} + +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); + + Thread t("Count", thread2Runner); + + t.start(); + timers.after(2000, sendFunc, &t); + + game->run(); + + game->quit(); + wnd->quit(); + + return 0; +} \ No newline at end of file diff --git a/test/03Thread/threadtest.cpp b/test/03Thread/threadtest.cpp deleted file mode 100644 index a792e53..0000000 --- a/test/03Thread/threadtest.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include "jin.h" - -using namespace std; -using namespace jin::core; -using namespace jin::graphics; -using namespace jin::input; -using namespace jin::audio; -using namespace jin::time; -using namespace jin::thread; - -Timers timers; - -void onEvent(jin::input::Event* e) -{ - static Game* game = Game::get(); - if (e->type == EventType::QUIT) - game->stop(); -} - -void onUpdate(int ms) -{ - timers.update(ms); -} - -void onDraw() -{ - -} - -void thread2Runner(Thread* t) -{ - int i = 0; - while (true) - { - if (i++ == 1000000000) - { - i = 0; - cout << (char*)(t->demand(1).pointer); - } - } -} - -void sendFunc(void* p) -{ - Thread* t = (Thread*)p; - t->send(1, "hello_"); -} - -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); - - Thread t("Count", thread2Runner); - - t.start(); - timers.after(2000, sendFunc, &t); - - game->run(); - - game->quit(); - wnd->quit(); - - return 0; -} \ No newline at end of file diff --git a/test/04Network/main.cpp b/test/04Network/main.cpp new file mode 100644 index 0000000..a792e53 --- /dev/null +++ b/test/04Network/main.cpp @@ -0,0 +1,83 @@ +#include +#include +#include "jin.h" + +using namespace std; +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; +using namespace jin::time; +using namespace jin::thread; + +Timers timers; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + timers.update(ms); +} + +void onDraw() +{ + +} + +void thread2Runner(Thread* t) +{ + int i = 0; + while (true) + { + if (i++ == 1000000000) + { + i = 0; + cout << (char*)(t->demand(1).pointer); + } + } +} + +void sendFunc(void* p) +{ + Thread* t = (Thread*)p; + t->send(1, "hello_"); +} + +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); + + Thread t("Count", thread2Runner); + + t.start(); + timers.after(2000, sendFunc, &t); + + game->run(); + + game->quit(); + wnd->quit(); + + return 0; +} \ No newline at end of file -- cgit v1.1-26-g67d0