Emscripten 声称我在不使用 requestAnimationFrame 的情况下进行渲染

Emscripten claims I'm rendering without using requestAnimationFrame

我一直在尝试使用 emscripten 在线 运行 我的 c++ 程序。然而,它一直用 :

的错误轰炸我

Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!

但是,据我所知,问题是我在 emscripten_set_main_loop_arg 中设置了 0 fps。所以,我无法理解为什么当我确实使用 requestAnimationFrame 渲染时会收到此错误。

这是我的主循环的一般分解:

static void dispatchMain(void* fp)
{
    std::function<void()>* function = (std::function<void()>*)fp;
    (*function)();
}

void main()
{
    std::function<void()> mainLoop = [&]() {
        // Main loop calls here
    };

    emscripten_set_main_loop_arg(dispatchMain, &mainLoop, 0, 1);
}

编译命令的一般分解如下:

emcc -std=c++11 "Main.cpp" -s USE_GLFW=3 -s FULL_ES3=1 -DEMSCRIPTEN=1 -s TOTAL_MEMORY=167772160 -O3 -o out.html

问题是,出于某种原因使用

glTimeinterval(0) 

在 window class 中搞砸了帧率并导致了错误。