Skip to content

Commit

Permalink
feat: fixing issues with rendering primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTroble committed Jun 12, 2024
1 parent 838eda4 commit 2144f79
Show file tree
Hide file tree
Showing 9 changed files with 1,861 additions and 1,765 deletions.
15 changes: 12 additions & 3 deletions TGEngine/private/TGEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,23 @@ namespace tge::main {

using namespace std::chrono;
auto startpoint = steady_clock::now();
double deltatime = 0;
std::array<double, 10> deltaTimes{ 0 };
size_t currentIndex = 0;
isRunning = true;
for (;;) {
if (util::exitRequest || winModule->closeRequest) break;
for (auto mod : modules) mod->tick(deltatime);
double average = 0;
for (const auto time : deltaTimes)
{
average += time;
}
average /= deltaTimes.size();
for (auto mod : modules) mod->tick(average);

auto endpoint = steady_clock::now();
deltatime = duration_cast<duration<double>>(endpoint - startpoint).count();
const std::chrono::duration<double> newDeltaTime = endpoint - startpoint;
deltaTimes[currentIndex] = newDeltaTime.count();
currentIndex = (currentIndex + 1) % deltaTimes.size();
startpoint = endpoint;
}
for (auto bItr = modules.rbegin(); bItr < modules.rend(); bItr++) {
Expand Down
Loading

0 comments on commit 2144f79

Please sign in to comment.