hibiscus/core/application/application.cpp

51 lines
1.4 KiB
C++
Raw Permalink Normal View History

2023-05-26 21:41:51 +00:00
#include "enginever.hpp"
#include "engine.hpp"
2023-05-30 14:20:34 +00:00
#include "../pragmautil.hpp"
#include <core/graphics/drawable.hpp>
2023-05-26 21:41:51 +00:00
namespace hibis {
Engine::Engine(Renderer* renderer, LoggerCallback logger) {
this->mRenderer = renderer;
mLoggerCallback = logger;
mPreviousProcessTick = std::chrono::steady_clock::now();
mPreviousPhysicsProcessTick = std::chrono::steady_clock::now();
2023-05-26 21:41:51 +00:00
//watch.start();
mLoggerCallback(Information, "Starting FreeType2 library...");
int err = FT_Init_FreeType(&mFreeTypeLibrary);
if (err) {
mLoggerCallback(Fatal, "Failed to init FreeType2");
}
mLoggerCallback(Information, "Started Hibis [using v" + (std::string)getEngineVersion() + "]!");
2023-05-26 21:41:51 +00:00
}
Engine::~Engine() {
//watch.stop();
}
2023-06-26 14:08:19 +00:00
float Engine::calculateDelta(bool isPhysics) {
const std::chrono::time_point<std::chrono::steady_clock> current = std::chrono::steady_clock::now();
2023-06-26 14:08:19 +00:00
if (isPhysics) {
auto delta = std::chrono::duration<float>(current - mPreviousPhysicsProcessTick);
2023-05-26 21:41:51 +00:00
2023-06-26 14:08:19 +00:00
return delta.count();
} else {
auto delta = std::chrono::duration<float>(current - mPreviousProcessTick);
2023-05-26 21:41:51 +00:00
2023-06-26 14:08:19 +00:00
return delta.count();
2023-05-26 21:41:51 +00:00
}
}
2023-06-26 14:08:19 +00:00
void Engine::updateDelta(bool isPhysics) {
if (isPhysics) {
mPreviousPhysicsProcessTick = std::chrono::steady_clock::now();
} else {
mPreviousProcessTick = std::chrono::steady_clock::now();
}
2023-05-26 21:41:51 +00:00
}
const char* Engine::getEngineVersion() { return HIBIS_VERSION; }
}