Skip to content

Commit c82c310

Browse files
committed
Improve JavaScript debug messages
Tries to write the enumeration value for numbers if possible to improve readability of the parameters. Change-Id: I37163fb3b09be3de7280786ddbc2fd42dfef8750 Reviewed-by: Michael Winkelmann <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
1 parent d087763 commit c82c310

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/plugins/platforms/webgl/webqt.jsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,19 @@ window.onload = function () {
920920
console.log("executing " + d.glCommands.length + " commands");
921921
while (d.glCommands.length) {
922922
var obj = d.glCommands.shift();
923-
if (DEBUG)
924-
console.log("Calling: gl." + obj.function, obj.parameters);
923+
if (DEBUG) {
924+
var parameters = [];
925+
for (var key in obj.parameters) {
926+
if (typeof obj.parameters[key] === 'number' &&
927+
d.glConstants[obj.parameters[key]] !== undefined) {
928+
parameters[key] = d.glConstants[obj.parameters[key]] + ' (' +
929+
obj.parameters[key] + ')';
930+
} else {
931+
parameters[key] = obj.parameters[key];
932+
}
933+
}
934+
console.log("Calling: gl." + obj.function, parameters);
935+
}
925936
var response = gl[obj.function].apply(gl, obj.parameters);
926937
if (response !== undefined)
927938
sendResponse(obj.id, response);
@@ -1017,10 +1028,20 @@ window.onload = function () {
10171028
gl = windowData[winId].gl;
10181029
currentWindowId = winId;
10191030
currentContext = obj.parameters[0];
1020-
if (DEBUG)
1021-
console.log("Current context is now " + currentContext);
10221031
if (currentContext)
10231032
ensureContextData(currentContext);
1033+
if (DEBUG) {
1034+
console.log("Current context is now " + currentContext);
1035+
var d = contextData[currentContext];
1036+
if (d.glConstants === undefined) {
1037+
d.glConstants = {};
1038+
for (var key in gl) {
1039+
if (typeof gl[key] === 'number') {
1040+
d.glConstants[gl[key]] = 'gl.' + key;
1041+
}
1042+
}
1043+
}
1044+
}
10241045
}
10251046
} else if (obj.function === "swapBuffers") {
10261047
var data = windowData[currentWindowId];

0 commit comments

Comments
 (0)