mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 20:48:04 +00:00
More webgl bindings and fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
15
vendor/wasm/WebGL/webgl2.odin
vendored
15
vendor/wasm/WebGL/webgl2.odin
vendored
@@ -104,6 +104,12 @@ foreign webgl2 {
|
||||
GetUniformBlockIndex :: proc(program: Program, uniformBlockName: string) -> i32 ---
|
||||
UniformBlockBinding :: proc(program: Program, uniformBlockIndex: i32, uniformBlockBinding: i32) ---
|
||||
|
||||
// if `pname` is `UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES` then an array will be written at
|
||||
// `params`, in that case the length `params` need to have is given first querying using `pname`
|
||||
// `UNIFORM_BLOCK_ACTIVE_UNIFORMS`.
|
||||
GetActiveUniformBlockParameter :: proc(program: Program, uniformBlockIndex: i32, pname: Enum, params: [^]i32) ---
|
||||
GetActiveUniforms :: proc(program: Program, uniformIndices: []u32, pname: Enum, res: [^]i32) ---
|
||||
|
||||
CreateVertexArray :: proc() -> VertexArrayObject ---
|
||||
DeleteVertexArray :: proc(vertexArray: VertexArrayObject) ---
|
||||
IsVertexArray :: proc(vertexArray: VertexArrayObject) -> bool ---
|
||||
@@ -112,6 +118,7 @@ foreign webgl2 {
|
||||
|
||||
GetActiveUniformBlockNameBuf :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string {
|
||||
foreign webgl2 {
|
||||
@(link_name="GetActiveUniformBlockName")
|
||||
_GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) ---
|
||||
}
|
||||
n: int
|
||||
@@ -121,6 +128,7 @@ GetActiveUniformBlockNameBuf :: proc(program: Program, uniformBlockIndex: i32, b
|
||||
|
||||
GetActiveUniformBlockNameAlloc :: proc(program: Program, uniformBlockIndex: i32, allocator: runtime.Allocator, loc := #caller_location) -> string {
|
||||
foreign webgl2 {
|
||||
@(link_name="GetActiveUniformBlockName")
|
||||
_GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) ---
|
||||
}
|
||||
n: int
|
||||
@@ -141,7 +149,6 @@ GetActiveUniformBlockName :: proc {
|
||||
GetActiveUniformBlockNameAlloc,
|
||||
}
|
||||
|
||||
|
||||
Uniform1uiv :: proc "contextless" (location: i32, v: u32) {
|
||||
Uniform1ui(location, v)
|
||||
}
|
||||
@@ -157,6 +164,7 @@ Uniform4uiv :: proc "contextless" (location: i32, v: glm.uvec4) {
|
||||
|
||||
UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix3x2fv")
|
||||
_UniformMatrix3x2fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
@@ -164,6 +172,7 @@ UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) {
|
||||
}
|
||||
UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix4x2fv")
|
||||
_UniformMatrix4x2fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
@@ -171,6 +180,7 @@ UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) {
|
||||
}
|
||||
UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix2x3fv")
|
||||
_UniformMatrix2x3fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
@@ -178,6 +188,7 @@ UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) {
|
||||
}
|
||||
UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix4x3fv")
|
||||
_UniformMatrix4x3fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
@@ -185,6 +196,7 @@ UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) {
|
||||
}
|
||||
UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix2x4fv")
|
||||
_UniformMatrix2x4fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
@@ -192,6 +204,7 @@ UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) {
|
||||
}
|
||||
UniformMatrix3x4fv :: proc "contextless" (location: i32, m: glm.mat3x4) {
|
||||
foreign webgl2 {
|
||||
@(link_name="UniformMatrix3x4fv")
|
||||
_UniformMatrix3x4fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||
}
|
||||
array := intrinsics.matrix_flatten(m)
|
||||
|
||||
Reference in New Issue
Block a user