Created
September 1, 2011 20:26
-
-
Save chadbrewbaker/1187181 to your computer and use it in GitHub Desktop.
Hellow world in WebCL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input type="button" onclick="detectCL()" value="Run Lesson 1"> | |
| <script type="text/javascript"> | |
| function detectCL() { | |
| // First check if the WebCL extension is installed at all | |
| if (window.WebCL == undefined) { | |
| alert("Unfortunately your system does not support WebCL. " + | |
| "Make sure that you have both the OpenCL driver " + | |
| "and the WebCL browser extension installed."); | |
| return false; | |
| } | |
| // Get a list of available CL platforms, and another list of the | |
| // available devices on each platform. If there are no platforms, | |
| // or no available devices on any platform, then we can conclude | |
| // that WebCL is not available. | |
| try { | |
| var platforms = WebCL.getPlatformIDs(); | |
| var devices = []; | |
| for (var i in platforms) { | |
| var plat = platforms[i]; | |
| devices[i] = plat.getDeviceIDs(WebCL.CL_DEVICE_TYPE_ALL); | |
| } | |
| alert("Excellent! Your system does support WebCL."); | |
| } catch (e) { | |
| alert("Unfortunately platform or device inquiry failed."); | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment