39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#include "Gedeng/Application.h"
|
|
#include "Gedeng/Input.h"
|
|
#include "Gedeng/Logger.h"
|
|
#include "Gedeng/RenderBackend.h"
|
|
#include "Gedeng/Time.h"
|
|
|
|
namespace Gedeng {
|
|
|
|
void Application::run() {
|
|
// Setup Rendering
|
|
// FIXME: Make these parameters variable, maybe move this to a different function
|
|
RenderBackend::initialize_window(1920, 1080, String("Application"));
|
|
Input::initialize(RenderBackend::get_window());
|
|
|
|
unsigned long previous_time_ms = Time::get_time_ms();
|
|
unsigned long time_until_fixed_update_ms = 0.0;
|
|
|
|
while (!RenderBackend::does_window_want_to_close()) {
|
|
unsigned long current_time_ms = Time::get_time_ms();
|
|
unsigned long elapsed_time_ms = current_time_ms - previous_time_ms;
|
|
|
|
previous_time_ms = current_time_ms;
|
|
time_until_fixed_update_ms += elapsed_time_ms;
|
|
|
|
Input::poll_input();
|
|
|
|
// Update fixed time step
|
|
while (time_until_fixed_update_ms >= MS_PER_UPDATE) {
|
|
// Fixed Update
|
|
GG_CORE_INFO("Fixed Update");
|
|
time_until_fixed_update_ms -= MS_PER_UPDATE;
|
|
}
|
|
|
|
// Variable update
|
|
GG_CORE_INFO("Variable Update");
|
|
}
|
|
}
|
|
|
|
} // namespace Gedeng
|