- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, if "gl==null", it means that the browser is not support WebGL. WebGL is not commonly supported on many mobile platforms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anatoly - I don't understand. Are you saying you got it to work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in mobile chrome (if you enable the hardware rasterization) gl == WebglRenderingContext
in intel xdk gl == null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in Mobile chrome( android): gl==webglRenderingContext
in Intel XDK Emulator: gl==webglRenderingContext
Intel xdk debug mode: gl==null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 <
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page