diff --git a/test/webGL-Test.html b/test/webGL-Test.html index d7a10e1..9882632 100644 --- a/test/webGL-Test.html +++ b/test/webGL-Test.html @@ -8,7 +8,16 @@

webGL test

-Checks if the addon also supports webGL. +

Expected result

+ +

Support

+

Parameters

+
\ No newline at end of file diff --git a/test/webGL-Test.js b/test/webGL-Test.js index e3ab7ea..0834f12 100644 --- a/test/webGL-Test.js +++ b/test/webGL-Test.js @@ -22,9 +22,72 @@ values[pixels[i]] = (values[pixels[i]] || 0) + 1; max = Math.max(max, values[pixels[i]]); } - - output.textContent = context + ": " + (max !== 3 * values[255]? "": "not ") + "supported"; - output.title = JSON.stringify(values); + const parameters = []; + for (var name in gl){ + if (name.toUpperCase() === name){ + var value = gl.getParameter(gl[name]); + if (value !== null){ + parameters.push({name: name, value: value}); + } + } + } + const debugExtension = gl.getExtension("WEBGL_debug_renderer_info"); + + for (name in debugExtension){ + if (name.toUpperCase() === name){ + value = gl.getParameter(debugExtension[name]); + if (value !== null){ + parameters.push({name: name, value: value}); + } + } + } + var frontParameters = ["VENDOR", "RENDERER", "UNMASKED_VENDOR_WEBGL", "UNMASKED_RENDERER_WEBGL"]; + parameters.sort(function(a, b){ + var frontA = frontParameters.indexOf(a.name); + var frontB = frontParameters.indexOf(b.name); + if (frontA !== -1){ + if (frontB !== -1){ + return frontA - frontB; + } + else { + return -1; + } + } + else { + if (frontB !== -1){ + return 1; + } + else { + return a.name < b.name? -1: 1; + } + } + }); + if (context === "webgl2"){ + var parameterOutput = document.createElement("table"); + document.getElementById("parameters").appendChild(parameterOutput); + parameters.forEach(function(parameter){ + var parameterRow = document.createElement("tr"); + parameterRow.innerHTML = "" + parameter.name + "" + parameter.value + ""; + parameterOutput.appendChild(parameterRow); + }); + } + crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode(parameters.map(function(parameter){ + return parameter.name + ": " + parameter.value; + }).join(","))) + .then(function(hash){ + var chunks = []; + (new Uint32Array(hash)).forEach(function(num){ + chunks.push(num.toString(16)); + }); + return chunks.map(function(chunk){ + return "0".repeat(8 - chunk.length) + chunk; + }).join(""); + }).then(function(hash) { + output.textContent = context + ": " + + (max !== 3 * values[255]? "": "not ") + "supported " + + "(parameter hash: " + hash + ")"; + output.title = JSON.stringify(values); + }); } catch (e){ output.textContent = context + ": ERROR";