Skip to content

Instantly share code, notes, and snippets.

@didasy
Created July 4, 2015 13:17
Show Gist options
  • Save didasy/a27062b8fd9936576633 to your computer and use it in GitHub Desktop.
Save didasy/a27062b8fd9936576633 to your computer and use it in GitHub Desktop.
Finding GPU Info via JS
var canvas = $('<canvas />', { width: '1', height: '1' }).appendTo('body');
var webglVersion = window.location.search.indexOf('v=2') > 0 ? 2 : 1;
var gl;
var possibleNames = (webglVersion === 2) ? ['webgl2', 'experimental-webgl2'] : ['webgl', 'experimental-webgl'];
var contextName;
possibleNames.forEach(function (name) {
gl = canvas[0].getContext(name, { stencil : true });
contextName = !!gl;
});
canvas.remove();
function getUnmaskedInfo(gl) {
var unMaskedInfo = {
renderer: '',
vendor: ''
};
var dbgRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
if (dbgRenderInfo != null) {
unMaskedInfo.renderer = gl.getParameter(dbgRenderInfo.UNMASKED_RENDERER_WEBGL);
unMaskedInfo.vendor = gl.getParameter(dbgRenderInfo.UNMASKED_VENDOR_WEBGL);
}
return unMaskedInfo;
}
console.log(getUnmaskedInfo(gl));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment