From 220a6cba1c2bd015b74504013d04b11892f12453 Mon Sep 17 00:00:00 2001 From: Fedor Logachev Date: Sat, 2 Sep 2023 22:03:06 -0600 Subject: [PATCH] js: missing gl.js functions + enabled some extensions Those extensions should be safe enough to rely on, but even if there are non present - everything will almsot work.. --- js/gl.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/gl.js b/js/gl.js index 3ce9e2d4..0911e4c8 100644 --- a/js/gl.js +++ b/js/gl.js @@ -77,6 +77,13 @@ function acquireDisjointTimerQueryExtension(ctx) { } } +try { + gl.getExtension("EXT_shader_texture_lod"); + gl.getExtension("OES_standard_derivatives"); +} catch (e) { + console.warn(e); +} + acquireVertexArrayObjectExtension(gl); acquireInstancedArraysExtension(gl); acquireDisjointTimerQueryExtension(gl); @@ -949,6 +956,18 @@ var importObject = { array[i] = log.charCodeAt(i); } }, + glGetString: function(id) { + // getParameter returns "any": it could be GLenum, String or whatever, + // depending on the id. + var parameter = gl.getParameter(id).toString(); + console.log(parameter); + var len = parameter.length + 1; + var msg = wasm_exports.allocate_vec_u8(len); + var array = new Uint8Array(wasm_memory.buffer, msg, len); + array[parameter.length] = 0; + stringToUTF8(parameter, array, 0, len); + return msg; + }, glCompileShader: function (shader, count, string, length) { GL.validateGLObjectID(GL.shaders, shader, 'glCompileShader', 'shader'); gl.compileShader(GL.shaders[shader]); @@ -1061,6 +1080,10 @@ var importObject = { heap[0] = result; heap[1] = (result - heap[0])/4294967296; }, + glGenerateMipmap: function (index) { + gl.generateMipmap(index); + }, + setup_canvas_size: function(high_dpi) { window.high_dpi = high_dpi; resize(canvas);