aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/game/je_application.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-14 14:55:42 +0800
committerchai <chaifix@163.com>2018-12-14 14:55:42 +0800
commit870fcdae66edc680cac55defb149e1434e865f37 (patch)
treebb0b45627b98ec4c782466b3bb57daf63c44e460 /src/libjin/game/je_application.cpp
parenteb8ca083c9be574acd27cf0de41d1f69146cad7a (diff)
*格式化代码
Diffstat (limited to 'src/libjin/game/je_application.cpp')
-rw-r--r--src/libjin/game/je_application.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/libjin/game/je_application.cpp b/src/libjin/game/je_application.cpp
index 1a3c5ed..19a74a0 100644
--- a/src/libjin/game/je_application.cpp
+++ b/src/libjin/game/je_application.cpp
@@ -18,64 +18,64 @@ using namespace JinEngine::Math;
namespace JinEngine
{
- namespace Game
- {
+ namespace Game
+ {
- Application::Application() :_running(true) {};
+ Application::Application() :_running(true) {};
- /* default game loop */
- void Application::run()
- {
- if (_onLoad != nullptr)
- _onLoad();
- Window* wnd = Window::get();
- const int FPS = wnd ? wnd->getFPS() : 60;
- const int MS_PER_UPDATE = 1000.0f / FPS;
- _running = true;
- Event e;
- int current = getMilliSecond();
- int previous = current;
- int dt = 0;
- while (_running)
- {
- while (JinEngine::Input::pollEvent(&e))
- {
- if (_onEvent != nullptr)
- _onEvent(&e);
- if (!_running)
- goto quitloop;
- }
- previous = current;
- current = getMilliSecond();
- dt = current - previous;
- if (_onUpdate != nullptr)
- _onUpdate(dt);
+ /* default game loop */
+ void Application::run()
+ {
+ if (_onLoad != nullptr)
+ _onLoad();
+ Window* wnd = Window::get();
+ const int FPS = wnd ? wnd->getFPS() : 60;
+ const int MS_PER_UPDATE = 1000.0f / FPS;
+ _running = true;
+ Event e;
+ int current = getMilliSecond();
+ int previous = current;
+ int dt = 0;
+ while (_running)
+ {
+ while (JinEngine::Input::pollEvent(&e))
+ {
+ if (_onEvent != nullptr)
+ _onEvent(&e);
+ if (!_running)
+ goto quitloop;
+ }
+ previous = current;
+ current = getMilliSecond();
+ dt = current - previous;
+ if (_onUpdate != nullptr)
+ _onUpdate(dt);
glClear(GL_COLOR_BUFFER_BIT);
- if (_onDraw != nullptr)
- _onDraw();
- wnd->swapBuffers();
- sleep(16);
- }
- quitloop:;
- }
+ if (_onDraw != nullptr)
+ _onDraw();
+ wnd->swapBuffers();
+ sleep(16);
+ }
+ quitloop:;
+ }
- bool Application::startSystem(const SettingBase* setting)
- {
- if (setting == nullptr)
- return false;
- Application::Setting* s = (Application::Setting*) setting;
- _onEvent = s->eventHandler;
- _onUpdate = s->updater;
- _onDraw = s->drawer;
- _onLoad = s->loader;
- return true;
- }
+ bool Application::startSystem(const SettingBase* setting)
+ {
+ if (setting == nullptr)
+ return false;
+ Application::Setting* s = (Application::Setting*) setting;
+ _onEvent = s->eventHandler;
+ _onUpdate = s->updater;
+ _onDraw = s->drawer;
+ _onLoad = s->loader;
+ return true;
+ }
- void Application::quitSystem()
- {
- }
+ void Application::quitSystem()
+ {
+ }
- } // namespace Core
+ } // namespace Core
} // namespace JinEngine
#endif // jin_game \ No newline at end of file