Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

Webgl context

Анатолий_Г_
1,215 Views

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

0 Kudos
7 Replies
Zhen_Z_Intel
Employee
1,215 Views

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

0 Kudos
Анатолий_Г_
1,215 Views
webgl earned after enabling the hardware rasterization in the mobile chrome
0 Kudos
Pamela_H_Intel
Moderator
1,215 Views

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

0 Kudos
Анатолий_Г_
1,215 Views

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

in intel xdk gl == null

0 Kudos
Zhen_Z_Intel
Employee
1,215 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. 

0 Kudos
Анатолий_Г_
1,215 Views

in Mobile chrome( android): gl==webglRenderingContext

in Intel XDK Emulator: gl==webglRenderingContext 

Intel xdk debug mode: gl==null

 

0 Kudos
PaulF_IntelCorp
Employee
1,215 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 <

0 Kudos
Reply