Skip to content

Instantly share code, notes, and snippets.

@katp4
Forked from didasy/gpu.js
Created September 26, 2017 14:21
Show Gist options
  • Save katp4/dd9f653830036a3a5cfd511aed9a6591 to your computer and use it in GitHub Desktop.
Save katp4/dd9f653830036a3a5cfd511aed9a6591 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