a few notes and cleanup from previous merge

This commit is contained in:
Noel Berry 2021-01-05 20:44:02 -08:00
parent 66e8b34d37
commit 3fa9f99791
2 changed files with 71 additions and 69 deletions

View File

@ -14,15 +14,6 @@
using namespace Blah;
namespace
{
static Config app_config;
static bool app_is_running = false;
static bool app_is_exiting = false;
static uint64_t time_last;
static uint64_t time_accumulator = 0;
}
Config::Config()
{
name = nullptr;
@ -41,9 +32,16 @@ Config::Config()
on_error = nullptr;
}
namespace {
namespace
{
Config app_config;
bool app_is_running = false;
bool app_is_exiting = false;
uint64_t time_last;
uint64_t time_accumulator = 0;
void loop_iteration() {
void app_iterate()
{
// poll system events
PlatformBackend::frame();
@ -111,8 +109,9 @@ void loop_iteration() {
GraphicsBackend::after_render();
PlatformBackend::present();
}
}
}
} // namespace
bool App::run(const Config* c)
{
@ -154,13 +153,14 @@ bool App::run(const Config* c)
// display window
PlatformBackend::ready();
// Begin main loop
// Emscripten requires the main loop be separated into its own call
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop_iteration, 0, 1);
emscripten_set_main_loop(app_iterate, 0, 1);
#else
while (!app_is_exiting)
{
loop_iteration();
}
app_iterate();
#endif
// shutdown

View File

@ -147,6 +147,8 @@ void PlatformBackend::ready()
{
#ifndef __EMSCRIPTEN__
// enable V-Sync
// TODO:
// This should be a toggle or controllable in some way
if (App::renderer() == Renderer::OpenGL)
SDL_GL_SetSwapInterval(1);
#endif