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

时间:2018-04-29 06:36:23

标签: c++ emscripten

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

  

看起来你在不使用requestAnimationFrame进行主循环渲染。您应该在emscripten_set_main_loop中使用0作为帧速率才能使用requestAnimationFrame,因为这可以大大提高帧速率!

但问题是,据我所知,我在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

1 个答案:

答案 0 :(得分:0)

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

glTimeinterval(0) 
窗口类中的

搞砸了帧率并导致错误。