0

我正在使用以下示例 ppapi 插件,该插件使用 openGL 呈现旋转立方体:https ://chromium.googlesource.com/chromium/src/ppapi/+/master/examples/gles2_spinning_cube 。

我可以将其嵌入在 Chrome 中运行的网页中,并且一切正常。我的 html 页面的代码与此处相同:https ://chromium.googlesource.com/chromium/src/ppapi/+/master/examples/gles2_spinning_cube/gles2_spinning_cube.html

但是,如果我添加另一个embedhtml 元素以在同一页面上加载相同的插件两次,则只有第二个embed显示旋转立方体。第一个嵌入在停止之前渲染单个帧。

<embed id="plugin" type="application/x-ppapi-example-gles2-spinning-cube" width="800" height="600"/>
<embed id="plugin2" type="application/x-ppapi-example-gles2-spinning-cube" width="800" height="600"/>

Chrome 是否支持同一网页上的多个 ppapi 插件?如果这应该可以正常工作,那么有人可以帮我确定为什么会这样 - 这是因为我有多个 OpenGL 上下文还是什么?Fwiw,我在 Ubuntu 上,如有必要,我可以尝试在 Windows/Mac 上进行比较。我正在将 --register-pepper-plugin 与 Chrome 一起使用。

最终,我想将它与 CEF ( https://bitbucket.org/chromiumembedded/cef ) 一起使用,但由于这不适用于 Chrome,我想首先深入了解这个问题,然后再转向 CEF。

4

1 回答 1

1

是的,Chrome 确实支持同一页面上的多个 ppapi 插件,这是由于 ppapi 示例代码中缺少对 glSetCurrentContextPPAPI 的调用。它应该如下所示:

void DemoInstance::Paint(int32_t result) {
  if (result != PP_OK || !context_)
    return;

  glSetCurrentContextPPAPI(context_->pp_resource()); // missing from example

  cube_.UpdateForTimeDelta(0.02f);
  cube_.Draw();
  context_->SwapBuffers(callback_factory_.NewCallback(&DemoInstance::Paint));
}
于 2015-07-21T19:36:23.653 回答