From c82c3103f3e875d7d5f79dc3c4b273e9644e4ded Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 31 Oct 2017 14:19:29 +0100 Subject: Improve JavaScript debug messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tries to write the enumeration value for numbers if possible to improve readability of the parameters. Change-Id: I37163fb3b09be3de7280786ddbc2fd42dfef8750 Reviewed-by: Michael Winkelmann Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Edward Welbourne --- src/plugins/platforms/webgl/webqt.jsx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/webgl/webqt.jsx b/src/plugins/platforms/webgl/webqt.jsx index 816621b..cea2da0 100644 --- a/src/plugins/platforms/webgl/webqt.jsx +++ b/src/plugins/platforms/webgl/webqt.jsx @@ -920,8 +920,19 @@ window.onload = function () { console.log("executing " + d.glCommands.length + " commands"); while (d.glCommands.length) { var obj = d.glCommands.shift(); - if (DEBUG) - console.log("Calling: gl." + obj.function, obj.parameters); + if (DEBUG) { + var parameters = []; + for (var key in obj.parameters) { + if (typeof obj.parameters[key] === 'number' && + d.glConstants[obj.parameters[key]] !== undefined) { + parameters[key] = d.glConstants[obj.parameters[key]] + ' (' + + obj.parameters[key] + ')'; + } else { + parameters[key] = obj.parameters[key]; + } + } + console.log("Calling: gl." + obj.function, parameters); + } var response = gl[obj.function].apply(gl, obj.parameters); if (response !== undefined) sendResponse(obj.id, response); @@ -1017,10 +1028,20 @@ window.onload = function () { gl = windowData[winId].gl; currentWindowId = winId; currentContext = obj.parameters[0]; - if (DEBUG) - console.log("Current context is now " + currentContext); if (currentContext) ensureContextData(currentContext); + if (DEBUG) { + console.log("Current context is now " + currentContext); + var d = contextData[currentContext]; + if (d.glConstants === undefined) { + d.glConstants = {}; + for (var key in gl) { + if (typeof gl[key] === 'number') { + d.glConstants[gl[key]] = 'gl.' + key; + } + } + } + } } } else if (obj.function === "swapBuffers") { var data = windowData[currentWindowId]; -- cgit v1.2.3