Skip to content

Commit

Permalink
Using emscripten_set_main_loop in sokol app allows async calls such a…
Browse files Browse the repository at this point in the history
…s wget.
  • Loading branch information
ambrus committed Oct 7, 2023
1 parent 5bfa842 commit 0212d66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -5782,8 +5782,8 @@ _SOKOL_PRIVATE void _sapp_emsc_unregister_eventhandlers() {
#endif
}

_SOKOL_PRIVATE EM_BOOL _sapp_emsc_frame(double time, void* userData) {
_SOKOL_UNUSED(userData);
_SOKOL_PRIVATE void _sapp_emsc_frame() {
const double time = emscripten_performance_now();
_sapp_timing_external(&_sapp.timing, time / 1000.0);

#if defined(SOKOL_WGPU)
Expand Down Expand Up @@ -5824,9 +5824,8 @@ _SOKOL_PRIVATE EM_BOOL _sapp_emsc_frame(double time, void* userData) {
_sapp_emsc_unregister_eventhandlers();
_sapp_call_cleanup();
_sapp_discard_state();
return EM_FALSE;
emscripten_cancel_main_loop();
}
return EM_TRUE;
}

_SOKOL_PRIVATE void _sapp_emsc_run(const sapp_desc* desc) {
Expand Down Expand Up @@ -5859,7 +5858,7 @@ _SOKOL_PRIVATE void _sapp_emsc_run(const sapp_desc* desc) {
sapp_set_icon(&desc->icon);

/* start the frame loop */
emscripten_request_animation_frame_loop(_sapp_emsc_frame, 0);
emscripten_set_main_loop(_sapp_emsc_frame, 0, false);

/* NOT A BUG: do not call _sapp_discard_state() here, instead this is
called in _sapp_emsc_frame() when the application is ordered to quit
Expand Down

0 comments on commit 0212d66

Please sign in to comment.