Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use emscripten_set_main_loop in sokol app #915

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading