Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bindings for uniform 1iv, 2iv, 3iv, 4iv in webgl #4507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/sys/wasm/js/odin.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,23 @@ class WebGLInterface {
Uniform3i: (location, v0, v1, v2) => { this.ctx.uniform3i(this.uniforms[location], v0, v1, v2); },
Uniform4i: (location, v0, v1, v2, v3) => { this.ctx.uniform4i(this.uniforms[location], v0, v1, v2, v3); },

Uniform1iv: (location, count, addr) => {
let array = this.mem.loadI32Array(addr, count);
this.ctx.uniform1iv(this.uniforms[location], array);
},
Uniform2iv: (location, count, addr) => {
let array = this.mem.loadI32Array(addr, count);
this.ctx.uniform2iv(this.uniforms[location], array);
},
Uniform3iv: (location, count, addr) => {
let array = this.mem.loadI32Array(addr, count);
this.ctx.uniform3iv(this.uniforms[location], array);
},
Uniform4iv: (location, count, addr) => {
let array = this.mem.loadI32Array(addr, count);
this.ctx.uniform4iv(this.uniforms[location], array);
},

UniformMatrix2fv: (location, addr) => {
let array = this.mem.loadF32Array(addr, 2*2);
this.ctx.uniformMatrix2fv(this.uniforms[location], false, array);
Expand Down
9 changes: 5 additions & 4 deletions vendor/wasm/WebGL/webgl.odin
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ foreign webgl {
Uniform3i :: proc(location: i32, v0, v1, v2: i32) ---
Uniform4i :: proc(location: i32, v0, v1, v2, v3: i32) ---

Uniform1iv :: proc(location: i32, count: i32, value: rawptr) ---
Uniform2iv :: proc(location: i32, count: i32, value: rawptr) ---
Uniform3iv :: proc(location: i32, count: i32, value: rawptr) ---
Uniform4iv :: proc(location: i32, count: i32, value: rawptr) ---

UseProgram :: proc(program: Program) ---
ValidateProgram :: proc(program: Program) ---

Expand All @@ -174,10 +179,6 @@ Uniform1fv :: proc "contextless" (location: i32, v: f32) { Uniform1f(locat
Uniform2fv :: proc "contextless" (location: i32, v: glm.vec2) { Uniform2f(location, v.x, v.y) }
Uniform3fv :: proc "contextless" (location: i32, v: glm.vec3) { Uniform3f(location, v.x, v.y, v.z) }
Uniform4fv :: proc "contextless" (location: i32, v: glm.vec4) { Uniform4f(location, v.x, v.y, v.z, v.w) }
Uniform1iv :: proc "contextless" (location: i32, v: i32) { Uniform1i(location, v) }
Uniform2iv :: proc "contextless" (location: i32, v: glm.ivec2) { Uniform2i(location, v.x, v.y) }
Uniform3iv :: proc "contextless" (location: i32, v: glm.ivec3) { Uniform3i(location, v.x, v.y, v.z) }
Uniform4iv :: proc "contextless" (location: i32, v: glm.ivec4) { Uniform4i(location, v.x, v.y, v.z, v.w) }
Comment on lines -177 to -180
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note you've just changed it to make it work for your use case and haven't touched the UniformNfv code above it to be "correct" either.

Copy link
Author

@Spad0n Spad0n Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I could have also updated the UniformNfv bindings. Would you prefer that I include these fixes in this PR, or would you rather I create a new one that includes both the UniformNiv and UniformNfv fixes ?


VertexAttrib1fv :: proc "contextless" (index: i32, v: f32) { VertexAttrib1f(index, v) }
VertexAttrib2fv :: proc "contextless" (index: i32, v: glm.vec2){ VertexAttrib2f(index, v.x, v.y) }
Expand Down