Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/emscripten_request_animation_frame_loop.c
7085 views
1
#include <emscripten/html5.h>
2
#include <assert.h>
3
#include <stdlib.h>
4
5
double previousRafTime = 0;
6
int funcExecuted = 0;
7
8
void testDone(void *userData) {
9
assert((long)userData == 2);
10
assert(funcExecuted == 10);
11
exit(0);
12
}
13
14
bool tick(double time, void *userData) {
15
assert(time > previousRafTime);
16
previousRafTime = time;
17
assert((long)userData == 1);
18
++funcExecuted;
19
if (funcExecuted == 10)
20
{
21
emscripten_set_timeout(testDone, 300, (void*)2);
22
}
23
return funcExecuted < 10;
24
}
25
26
int main() {
27
emscripten_request_animation_frame_loop(tick, (void*)1);
28
}
29
30