Skip to content

Commit

Permalink
native/wasm: missed gl functions
Browse files Browse the repository at this point in the history
  • Loading branch information
not-fl3 committed May 20, 2024
1 parent 838362b commit c26a3e6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion js/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ function acquireDisjointTimerQueryExtension(ctx) {
}
}

function acquireDrawBuffers(ctx) {
var ext = ctx.getExtension('WEBGL_draw_buffers');
if (ext) {
ctx['drawBuffers'] = function (bufs) { return ext['drawBuffersWEBGL'](bufs); };
}
}

try {
gl.getExtension("EXT_shader_texture_lod");
gl.getExtension("OES_standard_derivatives");
Expand All @@ -87,6 +94,7 @@ try {
acquireVertexArrayObjectExtension(gl);
acquireInstancedArraysExtension(gl);
acquireDisjointTimerQueryExtension(gl);
acquireDrawBuffers(gl);

// https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_depth_texture
if (gl.getExtension('WEBGL_depth_texture') == null) {
Expand Down Expand Up @@ -833,6 +841,9 @@ var importObject = {
glDrawArrays: function (mode, first, count) {
gl.drawArrays(mode, first, count);
},
glDrawBuffers: function (n, bufs) {
gl.drawBuffers(getArray(bufs, Int32Array, n));
},
glCreateProgram: function () {
var id = GL.getNewId(GL.programs);
var program = gl.createProgram();
Expand All @@ -845,7 +856,7 @@ var importObject = {
GL.validateGLObjectID(GL.shaders, shader, 'glAttachShader', 'shader');
gl.attachShader(GL.programs[program], GL.shaders[shader]);
},
glDettachShader: function (program, shader) {
glDetachShader: function (program, shader) {
GL.validateGLObjectID(GL.programs, program, 'glDetachShader', 'program');
GL.validateGLObjectID(GL.shaders, shader, 'glDetachShader', 'shader');
gl.detachShader(GL.programs[program], GL.shaders[shader]);
Expand Down Expand Up @@ -1017,6 +1028,12 @@ var importObject = {
gl.deleteShader(id);
GL.shaders[shader] = null
},
glDeleteProgram: function (program) {
var id = GL.programs[program];
if (id == null) { return }
gl.deleteProgram(id);
GL.programs[program] = null
},
glDeleteBuffers: function (n, buffers) {
for (var i = 0; i < n; i++) {
var id = getArray(buffers + i * 4, Uint32Array, 1)[0];
Expand Down

0 comments on commit c26a3e6

Please sign in to comment.