Community
cancel
Showing results for 
Search instead for 
Did you mean: 
129 Views

Webgl context

How to get webgl context for drawing?

This code does not work:

var canvas = document.createElement("canvas");
var namesContexts = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"];
var gl = null;
for (var ii = 0; ii < namesContexts.length; ii++) {
    try {
        gl = canvas.getContext(namesContexts[ii]);
    } catch (e) {}
    if (gl) {
        break;
    }
}

After executing this code  ... gl==null

Tags (2)
0 Kudos
7 Replies
Zhen_Z_Intel
Employee
129 Views

Hi, if "gl==null", it means that the browser is not support WebGL. WebGL is not commonly supported on many mobile platforms

129 Views

webgl earned after enabling the hardware rasterization in the mobile chrome
Pamela_H_Intel
Moderator
129 Views

Anatoly - I don't understand. Are you saying you got it to work?

129 Views

in mobile chrome (if you enable the hardware rasterization) gl == WebglRenderingContext

in intel xdk gl == null

Zhen_Z_Intel
Employee
129 Views

Hi, could you make sure the value you get is "null" in XDK emulator? The XDK emulator is actually an application runs inside node-Webkit which uses web runtime based on Chrome browser. The chrome support WebGL, that means the XDK emulator should support WebGL as well without installing any plugin. I used "console.log(gl)" to have a check, and the output is the object "WebGLRenderingContext". I attach the image, so that you could also double check with your code. 

129 Views

in Mobile chrome( android): gl==webglRenderingContext

in Intel XDK Emulator: gl==webglRenderingContext 

Intel xdk debug mode: gl==null

 

PaulF_IntelCorp
Employee
129 Views

The Debug tab is running in a Crosswalk webview (it is similar to building a Crosswalk app). According to the Crosswalk FAQ pages (https://crosswalk-project.org/documentation/about/faq.html):

Why won't WebGL work in Crosswalk on my device?

Chromium has a blacklist of GPUs which are know to cause stability and/or conformance problems when running WebGL. Chromium will disable WebGL if running on a device with one of the GPUs in this list.

Crosswalk uses the same blacklist. Consequently, if Crosswalk is running on a device with a blacklisted GPU, WebGL is disabled by default.

For more information about which GPUs are blacklisted and when, see the Khronos WebGL wiki.

You are likely testing on such a device.

To fix this, you need to see this FAQ > https://software.intel.com/en-us/xdk/faqs/crosswalk#crosswalk-animatable <

Reply