mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
a few notes and cleanup from previous merge
This commit is contained in:
parent
66e8b34d37
commit
3fa9f99791
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user