aboutsummaryrefslogtreecommitdiff
path: root/core/sys/wasm
diff options
context:
space:
mode:
authorKarl Zylinski <karl@zylinski.se>2025-12-27 01:41:59 +0100
committerKarl Zylinski <karl@zylinski.se>2025-12-27 01:41:59 +0100
commit159eab133b4b6dc9df6896d003134c1f0ccfde92 (patch)
treee9ecad07b9be9e385bcd242daf3f0716084e1a47 /core/sys/wasm
parent7dee25bdcc069bbb0ceb5d4a1ac1a9e3009bfb83 (diff)
More webgl bindings and fixes
Diffstat (limited to 'core/sys/wasm')
-rw-r--r--core/sys/wasm/js/odin.js29
1 files changed, 22 insertions, 7 deletions
diff --git a/core/sys/wasm/js/odin.js b/core/sys/wasm/js/odin.js
index b0a01f66c..0c617dd8e 100644
--- a/core/sys/wasm/js/odin.js
+++ b/core/sys/wasm/js/odin.js
@@ -626,7 +626,7 @@ class WebGLInterface {
},
GetActiveAttrib: (program, index, size_ptr, type_ptr, name_buf_ptr, name_buf_len, name_len_ptr) => {
- let info = this.ctx.getActiveAttrib(program, index);
+ const info = this.ctx.getActiveAttrib(this.programs[program], index);
if (size_ptr) {
this.mem.storeInt(size_ptr, info.size);
@@ -636,18 +636,18 @@ class WebGLInterface {
this.mem.storeI32(type_ptr, info.type);
}
- if name_buf_ptr && name_buf_len > 0 {
+ if (name_buf_ptr && name_buf_len > 0) {
let n = Math.min(name_buf_len, info.name.length);
let name = info.name.substring(0, n);
this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name));
this.mem.storeInt(name_len_ptr, n);
- } else if name_len_ptr {
+ } else if (name_len_ptr) {
this.mem.storeInt(name_len_ptr, info.name.length);
}
},
GetActiveUniform: (program, index, size_ptr, type_ptr, name_buf_ptr, name_buf_len, name_len_ptr) => {
- let info = this.ctx.getActiveUniform(program, index);
+ let info = this.ctx.getActiveUniform(this.programs[program], index);
if (size_ptr) {
this.mem.storeInt(size_ptr, info.size);
@@ -657,12 +657,12 @@ class WebGLInterface {
this.mem.storeI32(type_ptr, info.type);
}
- if name_buf_ptr && name_buf_len > 0 {
+ if (name_buf_ptr && name_buf_len > 0) {
let n = Math.min(name_buf_len, info.name.length);
let name = info.name.substring(0, n);
this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name));
this.mem.storeInt(name_len_ptr, n);
- } else if name_len_ptr {
+ } else if (name_len_ptr) {
this.mem.storeInt(name_len_ptr, info.name.length);
}
},
@@ -1301,7 +1301,6 @@ class WebGLInterface {
this.assertWebGL2();
return this.ctx.getUniformBlockIndex(this.programs[program], this.mem.loadString(uniformBlockName_ptr, uniformBlockName_len));
},
- // any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
GetActiveUniformBlockName: (program, uniformBlockIndex, buf_ptr, buf_len, length_ptr) => {
this.assertWebGL2();
let name = this.ctx.getActiveUniformBlockName(this.programs[program], uniformBlockIndex);
@@ -1311,6 +1310,22 @@ class WebGLInterface {
this.mem.loadBytes(buf_ptr, buf_len).set(new TextEncoder().encode(name))
this.mem.storeInt(length_ptr, n);
},
+ GetActiveUniforms: (program, uniformIndices_ptr, uniformIndices_len, pname, res_ptr) => {
+ thid.assertWebGL2();
+ let indices = this.mem.loadU32Array(uniformIndices_ptr, uniformIndices_len);
+ this.ctx.getActiveUniforms(this.programs[program], indices, pname)
+ this.mem.loadI32Array(res_ptr, indices.length).set(indices)
+ },
+ GetActiveUniformBlockParameter: (program, uniformBlockIndex, pname, params_ptr) => {
+ this.assertWebGL2();
+ let res = this.ctx.getActiveUniformBlockParameter(this.programs[program], uniformBlockIndex, pname);
+
+ if (e instanceof Uint32Array) { // for pname GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
+ this.mem.loadU32Array(params_ptr, res.length).set(res)
+ } else {
+ this.mem.storeI32(params_ptr, res)
+ }
+ },
UniformBlockBinding: (program, uniformBlockIndex, uniformBlockBinding) => {
this.assertWebGL2();
this.ctx.uniformBlockBinding(this.programs[program], uniformBlockIndex, uniformBlockBinding);