Skip to content

Instantly share code, notes, and snippets.

@chadbrewbaker
Created September 1, 2011 20:26
Show Gist options
  • Select an option

  • Save chadbrewbaker/1187181 to your computer and use it in GitHub Desktop.

Select an option

Save chadbrewbaker/1187181 to your computer and use it in GitHub Desktop.
Hellow world in WebCL
<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