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"
|
2023-05-27 17:11:46 +00:00
|
|
|
#include <core/graphics/drawable.hpp>
|
2023-05-26 21:41:51 +00:00
|
|
|
|
|
|
|
namespace hibis {
|
|
|
|
Engine::Engine(Renderer* renderer, LoggerCallback logger) {
|
2023-05-27 19:47:34 +00:00
|
|
|
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();
|
|
|
|
|
2023-06-01 17:27:14 +00:00
|
|
|
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) {
|
2023-05-27 17:11:46 +00:00
|
|
|
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-27 17:11:46 +00:00
|
|
|
}
|
2023-05-26 21:41:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* Engine::getEngineVersion() { return HIBIS_VERSION; }
|
|
|
|
}
|