Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created July 6, 2017 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizheming/c97d756090d04c5031b15eb5f8d5010a to your computer and use it in GitHub Desktop.
Save lizheming/c97d756090d04c5031b15eb5f8d5010a to your computer and use it in GitHub Desktop.
Detect iPhone Mode
<!-- https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/HardwareGPUInformation/HardwareGPUInformation.html -->
<!doctype html>
<html>
<body>
<canvas id="glcanvas" width="0" height="0"></canvas>
<script type="text/JavaScript">
var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var canvas;
canvas = document.getElementById("glcanvas");
var gl = canvas.getContext("experimental-webgl");
//document.write(gl.getParameter(gl.RENDERER) + "<br>");
//document.write(gl.getParameter(gl.VENDOR) + "<br>");
// document.write(getUnmaskedInfo(gl).vendor + "<br>");
document.write('Your GPU is ' + getUnmaskedInfo(gl).renderer + "<br>");
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;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment