9 #include "appeventhandler.h"
12 #include <rtti/typeinfo.h>
14 #include <nap/timer.h>
15 #include <nap/logger.h>
32 template<
typename APP,
typename HANDLER>
100 std::unique_ptr<APP> mApp =
nullptr;
101 std::unique_ptr<HANDLER> mHandler =
nullptr;
102 std::atomic<bool> mStop = {
false };
104 std::string mProjectInfo;
113 template<
typename APP,
typename HANDLER>
120 template<
typename APP,
typename HANDLER>
127 template<
typename APP,
typename HANDLER>
131 mApp = std::make_unique<APP>(core);
132 mHandler = std::make_unique<HANDLER>(*mApp);
137 template<
typename APP,
typename HANDLER>
141 this->mProjectInfo = projectInfo;
142 this->mProjectContext = context;
146 template<
typename APP,
typename HANDLER>
153 bool initialized = !this->mProjectInfo.empty() ?
154 mCore.initializeEngine(this->mProjectInfo, this->mProjectContext, error) :
155 mCore.initializeEngine(error);
157 if (!error.check(initialized,
"Unable to initialize engine"))
163 if (handle ==
nullptr)
168 std::string data_dir = mCore.getProjectInfo()->getDataDirectory();
170 nap::Logger::info(
"Current working directory: % s", data_dir.c_str());
173 if (!error.check(!mCore.getProjectInfo()->mDefaultData.empty(),
"Missing project data, %s 'Data' field is empty",
174 mCore.getProjectInfo()->getProjectDir().c_str()))
179 nap::Logger::info(
"Loading data: %s", data_file.c_str());
180 if (!error.check(mCore.getResourceManager()->loadFile(data_file, error),
"Failed to load data: %s", data_file.c_str()))
184 mCore.getResourceManager()->watchDirectory(data_dir);
187 if(!error.check(app.
init(error),
"Unable to initialize application"))
191 app_event_handler.
start();
194 std::function<void(
double)> update_call = std::bind(&APP::update, mApp.get(), std::placeholders::_1);
213 mCore.update(update_call);
221 delay_time = frame_time - timer.
getMillis();
222 if(delay_time.count() > 0)
223 std::this_thread::sleep_for(delay_time);
237 template<
typename APP,
typename HANDLER>
244 template<
typename APP,
typename HANDLER>