Path: blob/main/test/emscripten_request_animation_frame.c
7085 views
#include <emscripten/html5.h>1#include <assert.h>23int func1Executed = 0;4int func2Executed = 0;56bool func1(double time, void *userData);78bool func2(double time, void *userData) {9assert((long)userData == 2);10assert(time > 0);11++func2Executed;1213if (func2Executed == 1) {14// Test canceling an animation frame: register rAF() but then cancel it immediately15long id = emscripten_request_animation_frame(func1, (void*)2);16emscripten_cancel_animation_frame(id);1718emscripten_request_animation_frame(func2, (void*)2);19}20if (func2Executed == 2) {21assert(func1Executed == 1);22}23return 0;24}2526bool func1(double time, void *userData) {27assert((long)userData == 1);28assert(time > 0);29++func1Executed;3031assert(func1Executed == 1);3233emscripten_request_animation_frame(func2, (void*)2);3435return 0;36}3738int main() {39emscripten_request_animation_frame(func1, (void*)1);40}414243