#include "enginever.hpp" #include "engine.hpp" #include "../pragmautil.hpp" #include 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(); //watch.start(); this->mLoggerCallback(Information, "Started Hibis [using v" + (std::string)getEngineVersion() + "]!"); } Engine::~Engine() { //watch.stop(); } void Engine::runNodeProcesses() { TODO("check if delta calc is correct") TODO("get workaround for MSVC being fucking stupid (std::chrono + std::this_thread)") const std::chrono::time_point current = std::chrono::steady_clock::now(); auto delta = std::chrono::duration(current - mPreviousProcessTick); for (Node* node : mNodeList) { node->process(delta.count()); } mPreviousProcessTick = std::chrono::steady_clock::now(); } void Engine::runNodePhysicsProcesses() { const std::chrono::time_point current = std::chrono::steady_clock::now(); auto delta = std::chrono::duration(current - mPreviousProcessTick); for (Node* node : mNodeList) { node->physicsProcess(delta.count()); } mPreviousProcessTick = std::chrono::steady_clock::now(); } void Engine::drawNodes() { TODO("check if this works") for (Node* node : mNodeList) { if (Drawable* drawNode = (Drawable*)&node) { drawNode->draw(mRenderer); } } } const char* Engine::getEngineVersion() { return HIBIS_VERSION; } }