其实UE4开启WebGL很简单只需要添加已下代码:
WebBrowserSingleton.cpp
//Ning+ 20190430
BrowserSettings.plugins = STATE_ENABLED;
BrowserSettings.webgl = STATE_ENABLED;
CEFBrowserApp.cpp
//Ning+ 20190430
CommandLine->AppendSwitch("enable-gpu");
CommandLine->AppendSwitch("enable-gpu-compositing");
性能优化,具体看自己需要添加
//Ning+ 20190430
command_line->AppendSwitch("enable-native-gpu-memory-buffers");
command_line->AppendSwitch("enable-one-copy");
command_line->AppendSwitch("enable-viewport");
command_line->AppendSwitch("no-proxy-server");
command_line->AppendSwitch("no-sandbox");
command_line->AppendSwitchWithValue("num-raster-threads", "4");
command_line->AppendSwitch("renderer");
完成这些步骤后确实可以加载WebGL,但是你会发现不到几分钟就会卡住;
解决方法是利用VS的调试工具,当UE4卡住时候查看堆栈,定位到CEF消息循环事件,将此屏蔽,然后自定义消息循环事件;
这样才算是真正打开了UE4的WebGL功能;