agiro
agiro

Reputation: 2080

CefSharp - can't enable webgl

I'm initializing my Chromium Browser like this:

CefSettings settings = new CefSettings();
settings.CommandLineArgsDisabled = false;
settings.CefCommandLineArgs.Clear();
settings.CefCommandLineArgs.Add("enable-3d-apis", "1");
settings.CefCommandLineArgs.Add("enable-webgl-draft-extensions", "1");
settings.CefCommandLineArgs.Add("enable-gpu", "1");
settings.CefCommandLineArgs.Add("enable-webgl", "1");

Cef.Initialize(settings);
var chromeBrowser = new ChromiumWebBrowser();
chromeBrowser.Address = "http://get.webgl.org/";       
targetGrid.Children.Add(chromeBrowser);

So I try a lot of commands found here but to no avail. It does load the website and it says "my browser does support webgl but it isn't enabled." I should see a cube rotating by the way which I don't see. I looked for some SO threads regarding this, one of them complaining about the speed and I copied the initialization from there (only that command line args), still no luck. I also tried turning off the disabling commands before adding these like

settings.CefCommandLineArgs.Add("disable-webgl", "0");

without success. Could someone tell me how to initialize CefSharp 55's webgl properly?

Upvotes: 3

Views: 2879

Answers (1)

Peuczynski
Peuczynski

Reputation: 4733

The WPF one has many issues and I ended up using WinFormsHost to host the control in WPF. Only then I have full touch support and GPU acceleration.

Here is how I did it.

private CefSharp.WinForms.ChromiumWebBrowser wb_Main;

public MainWindow()
{
    var cs = new CefSharp.CefSettings();
    cs.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0";
    CefSharp.Cef.Initialize(cs);

    InitializeComponent();

    CefSharp.Cef.GetGlobalCookieManager().SetStoragePath(Directory.GetCurrentDirectory(), true);
    wb_Main = new ChromiumWebBrowser("about:blank");
    wfh_Main.Child = wb_Main;   //WinformsHost control
}

Upvotes: 1

Related Questions