share main loop iter logic with emscripten_*_loop and glut