-
-
Save katp4/dd9f653830036a3a5cfd511aed9a6591 to your computer and use it in GitHub Desktop.
Finding GPU Info via JS
This file contains 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
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