53 catch (
const std::exception&) {
147 while (window.isOpen()) {
153 if (presentedScene !=
nullptr)
try {
154 presentedScene->update(threadNum, deltaTime);
156 catch (
const std::exception& e) {
157 console.
error(
"Failed to update presented screen on update thread " + std::to_string(threadNum) +
" - " + e.what());
170 using namespace std::string_literals;
171 using namespace std::chrono_literals;
190 catch (
const std::exception& e) {
191 console.
error(
"Failed to call onBegin in application - "s + e.what());
196 for (std::function<
void()> setupFunc :
nodeSetupFuncs) setupFunc();
198 catch (
const std::exception& e) {
199 console.
error(
"Terminating application due to failure to setup nodes - "s + e.what());
205 for (
size_t i = 0; i < std::thread::hardware_concurrency(); i++)
209 auto previousTime = std::chrono::high_resolution_clock::now();
216 auto currentTime = std::chrono::high_resolution_clock::now();
217 deltaTime =
static_cast<float>(std::chrono::duration_cast<std::chrono::microseconds>(currentTime - previousTime).count());
218 previousTime = std::chrono::high_resolution_clock::now();
228 catch (
const std::exception& e) {
229 console.
error(
"Failed to present scene - "s + e.what());
243 while (!
tasks.empty())
try {
247 catch (
const std::exception& e) {
248 console.
error(
"Failed to execute task on main thread - "s + e.what());
257 catch (
const std::exception& e) {
258 console.
error(
"Failed to render presented scene - "s + e.what());
273 catch (
const std::exception& e) {
274 console.
error(
"Terminating application due to failure to cleanup nodes - "s + e.what());
std::string getAssetFolderPath() const
std::condition_variable threadSyncCondVar
static std::vector< std::function< void()> > nodeCleanupFuncs
std::condition_variable renderSyncCondVar
void runTaskOnMainThread(std::function< void()> task)
std::shared_ptr< Scene > presentedScene
const std::string applicationName
std::shared_ptr< Scene > sceneToPresent
std::mutex taskManagerMutex
std::list< std::thread > updateThreads
std::mutex threadSyncMutex
static std::vector< std::function< void()> > nodeSetupFuncs
void presentScene(const std::shared_ptr< Scene > &scene)
size_t getNumUpdateThreads() const noexcept
Application(const char *applicationName) noexcept
std::queue< std::function< void()> > tasks
Window & getWindow() noexcept
std::shared_ptr< Scene > getPresentedScene() noexcept
void update(size_t threadNum) noexcept
void load(const std::string &applicationName)
static void setupCore() noexcept
static void cleanupCore() noexcept
static void cleanupCore()
static void setupCore(std::optional< uint32_t > gpuID=std::optional< uint32_t >())
void create(const char *title)