|
@@ -1,18 +1,12 @@
|
|
|
-#include "app.hpp"
|
|
|
|
|
-
|
|
|
|
|
-#include "saura/core/app_base/app_base.hpp"
|
|
|
|
|
|
|
+#include "app_base.hpp"
|
|
|
|
|
+#include <memory>
|
|
|
|
|
|
|
|
namespace saura {
|
|
namespace saura {
|
|
|
-App::App() {
|
|
|
|
|
- is_running = true;
|
|
|
|
|
-
|
|
|
|
|
|
|
+void AppBase::run() {
|
|
|
os_ctx = std::make_unique<os::Context>();
|
|
os_ctx = std::make_unique<os::Context>();
|
|
|
- os_ctx->set_root_window_title(get_app_base()->get_title());
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-App::~App() {}
|
|
|
|
|
|
|
+ this->start();
|
|
|
|
|
|
|
|
-void App::run() {
|
|
|
|
|
const double fps_max = 60.0;
|
|
const double fps_max = 60.0;
|
|
|
const double period_max = 1.0 / fps_max;
|
|
const double period_max = 1.0 / fps_max;
|
|
|
const double perf_frequency = os_ctx->get_performance_frequency();
|
|
const double perf_frequency = os_ctx->get_performance_frequency();
|
|
@@ -21,9 +15,8 @@ void App::run() {
|
|
|
double begin_counter = 0.0;
|
|
double begin_counter = 0.0;
|
|
|
double end_counter = 0.0;
|
|
double end_counter = 0.0;
|
|
|
|
|
|
|
|
- get_app_base()->start();
|
|
|
|
|
|
|
+ while (!is_quit) {
|
|
|
|
|
|
|
|
- while (is_running) {
|
|
|
|
|
double counter_elapsed = begin_counter - end_counter;
|
|
double counter_elapsed = begin_counter - end_counter;
|
|
|
double dt = counter_elapsed / perf_frequency;
|
|
double dt = counter_elapsed / perf_frequency;
|
|
|
double fps = perf_frequency / counter_elapsed;
|
|
double fps = perf_frequency / counter_elapsed;
|
|
@@ -36,11 +29,12 @@ void App::run() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!os_ctx->update_events()) {
|
|
if (!os_ctx->update_events()) {
|
|
|
- is_running = false;
|
|
|
|
|
|
|
+ is_quit = true;
|
|
|
}
|
|
}
|
|
|
os_ctx->update();
|
|
os_ctx->update();
|
|
|
|
|
+ this->update(dt);
|
|
|
os_ctx->draw_begin();
|
|
os_ctx->draw_begin();
|
|
|
- get_app_base()->update(dt);
|
|
|
|
|
|
|
+ this->draw();
|
|
|
os_ctx->draw_end();
|
|
os_ctx->draw_end();
|
|
|
|
|
|
|
|
end_counter = begin_counter;
|
|
end_counter = begin_counter;
|
|
@@ -48,7 +42,6 @@ void App::run() {
|
|
|
|
|
|
|
|
os_ctx->sleep(period_max);
|
|
os_ctx->sleep(period_max);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- get_app_base()->stop();
|
|
|
|
|
|
|
+ this->stop();
|
|
|
}
|
|
}
|
|
|
} // namespace saura
|
|
} // namespace saura
|