Skip to content

Commit

Permalink
js: missing gl.js functions + enabled some extensions
Browse files Browse the repository at this point in the history
Those extensions should be safe enough to rely on, but even if there are non present - everything will almsot work..
  • Loading branch information
not-fl3 committed Sep 3, 2023
1 parent a466435 commit 220a6cb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions js/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 220a6cb

Please sign in to comment.