mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Update WebGL procedures to contextless calling convention
This commit is contained in:
Vendored
+32
-35
@@ -27,7 +27,7 @@ ContextAttributes :: distinct bit_set[ContextAttribute; u32]
|
|||||||
|
|
||||||
DEFAULT_CONTEXT_ATTRIBUTES :: ContextAttributes{}
|
DEFAULT_CONTEXT_ATTRIBUTES :: ContextAttributes{}
|
||||||
|
|
||||||
@(default_calling_convention="c")
|
@(default_calling_convention="contextless")
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
// CreateCurrentContextById must be called before `GetCurrentContextAttributes` if the user wants to
|
// CreateCurrentContextById must be called before `GetCurrentContextAttributes` if the user wants to
|
||||||
// set specific attributes, otherwise the default attributes will be set for the WebGL context
|
// set specific attributes, otherwise the default attributes will be set for the WebGL context
|
||||||
@@ -168,61 +168,59 @@ foreign webgl {
|
|||||||
Viewport :: proc(x, y, w, h: i32) ---
|
Viewport :: proc(x, y, w, h: i32) ---
|
||||||
}
|
}
|
||||||
|
|
||||||
Uniform1fv :: proc "c" (location: i32, v: f32) { Uniform1f(location, v) }
|
Uniform1fv :: proc "contextless" (location: i32, v: f32) { Uniform1f(location, v) }
|
||||||
Uniform2fv :: proc "c" (location: i32, v: glm.vec2) { Uniform2f(location, v.x, v.y) }
|
Uniform2fv :: proc "contextless" (location: i32, v: glm.vec2) { Uniform2f(location, v.x, v.y) }
|
||||||
Uniform3fv :: proc "c" (location: i32, v: glm.vec3) { Uniform3f(location, v.x, v.y, v.z) }
|
Uniform3fv :: proc "contextless" (location: i32, v: glm.vec3) { Uniform3f(location, v.x, v.y, v.z) }
|
||||||
Uniform4fv :: proc "c" (location: i32, v: glm.vec4) { Uniform4f(location, v.x, v.y, v.z, v.w) }
|
Uniform4fv :: proc "contextless" (location: i32, v: glm.vec4) { Uniform4f(location, v.x, v.y, v.z, v.w) }
|
||||||
Uniform1iv :: proc "c" (location: i32, v: i32) { Uniform1i(location, v) }
|
Uniform1iv :: proc "contextless" (location: i32, v: i32) { Uniform1i(location, v) }
|
||||||
Uniform2iv :: proc "c" (location: i32, v: glm.ivec2) { Uniform2i(location, v.x, v.y) }
|
Uniform2iv :: proc "contextless" (location: i32, v: glm.ivec2) { Uniform2i(location, v.x, v.y) }
|
||||||
Uniform3iv :: proc "c" (location: i32, v: glm.ivec3) { Uniform3i(location, v.x, v.y, v.z) }
|
Uniform3iv :: proc "contextless" (location: i32, v: glm.ivec3) { Uniform3i(location, v.x, v.y, v.z) }
|
||||||
Uniform4iv :: proc "c" (location: i32, v: glm.ivec4) { Uniform4i(location, v.x, v.y, v.z, v.w) }
|
Uniform4iv :: proc "contextless" (location: i32, v: glm.ivec4) { Uniform4i(location, v.x, v.y, v.z, v.w) }
|
||||||
|
|
||||||
VertexAttrib1fv :: proc "c" (index: i32, v: f32) { VertexAttrib1f(index, v) }
|
VertexAttrib1fv :: proc "contextless" (index: i32, v: f32) { VertexAttrib1f(index, v) }
|
||||||
VertexAttrib2fv :: proc "c" (index: i32, v: glm.vec2){ VertexAttrib2f(index, v.x, v.y) }
|
VertexAttrib2fv :: proc "contextless" (index: i32, v: glm.vec2){ VertexAttrib2f(index, v.x, v.y) }
|
||||||
VertexAttrib3fv :: proc "c" (index: i32, v: glm.vec3){ VertexAttrib3f(index, v.x, v.y, v.z) }
|
VertexAttrib3fv :: proc "contextless" (index: i32, v: glm.vec3){ VertexAttrib3f(index, v.x, v.y, v.z) }
|
||||||
VertexAttrib4fv :: proc "c" (index: i32, v: glm.vec4){ VertexAttrib4f(index, v.x, v.y, v.z, v.w) }
|
VertexAttrib4fv :: proc "contextless" (index: i32, v: glm.vec4){ VertexAttrib4f(index, v.x, v.y, v.z, v.w) }
|
||||||
|
|
||||||
UniformMatrix2fv :: proc "c" (location: i32, m: glm.mat2) {
|
UniformMatrix2fv :: proc "contextless" (location: i32, m: glm.mat2) {
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="UniformMatrix2fv")
|
@(link_name="UniformMatrix2fv")
|
||||||
_UniformMatrix2fv :: proc "c" (location: i32, value: [^]f32) ---
|
_UniformMatrix2fv :: proc "contextless" (location: i32, value: [^]f32) ---
|
||||||
}
|
}
|
||||||
value := transmute([2*2]f32)m
|
value := transmute([2*2]f32)m
|
||||||
_UniformMatrix2fv(location, &value[0])
|
_UniformMatrix2fv(location, &value[0])
|
||||||
}
|
}
|
||||||
UniformMatrix3fv :: proc "c" (location: i32, m: glm.mat3) {
|
UniformMatrix3fv :: proc "contextless" (location: i32, m: glm.mat3) {
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="UniformMatrix3fv")
|
@(link_name="UniformMatrix3fv")
|
||||||
_UniformMatrix3fv :: proc "c" (location: i32, value: [^]f32) ---
|
_UniformMatrix3fv :: proc "contextless" (location: i32, value: [^]f32) ---
|
||||||
}
|
}
|
||||||
value := transmute([3*3]f32)m
|
value := transmute([3*3]f32)m
|
||||||
_UniformMatrix3fv(location, &value[0])
|
_UniformMatrix3fv(location, &value[0])
|
||||||
}
|
}
|
||||||
UniformMatrix4fv :: proc "c" (location: i32, m: glm.mat4) {
|
UniformMatrix4fv :: proc "contextless" (location: i32, m: glm.mat4) {
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="UniformMatrix4fv")
|
@(link_name="UniformMatrix4fv")
|
||||||
_UniformMatrix4fv :: proc "c" (location: i32, value: [^]f32) ---
|
_UniformMatrix4fv :: proc "contextless" (location: i32, value: [^]f32) ---
|
||||||
}
|
}
|
||||||
value := transmute([4*4]f32)m
|
value := transmute([4*4]f32)m
|
||||||
_UniformMatrix4fv(location, &value[0])
|
_UniformMatrix4fv(location, &value[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
GetShaderiv :: proc "c" (shader: Shader, pname: Enum) -> (p: i32) {
|
GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum) -> (p: i32) {
|
||||||
@(default_calling_convention="c")
|
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="GetShaderiv")
|
@(link_name="GetShaderiv")
|
||||||
_GetShaderiv :: proc "c" (shader: Shader, pname: Enum, p: ^i32) ---
|
_GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum, p: ^i32) ---
|
||||||
}
|
}
|
||||||
_GetShaderiv(shader, pname, &p)
|
_GetShaderiv(shader, pname, &p)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GetProgramInfoLog :: proc "c" (program: Program, buf: []byte) -> string {
|
GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte) -> string {
|
||||||
@(default_calling_convention="c")
|
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="GetProgramInfoLog")
|
@(link_name="GetProgramInfoLog")
|
||||||
_GetProgramInfoLog :: proc "c" (program: Program, buf: []byte, length: ^int) ---
|
_GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte, length: ^int) ---
|
||||||
}
|
}
|
||||||
|
|
||||||
length: int
|
length: int
|
||||||
@@ -230,11 +228,10 @@ GetProgramInfoLog :: proc "c" (program: Program, buf: []byte) -> string {
|
|||||||
return string(buf[:length])
|
return string(buf[:length])
|
||||||
}
|
}
|
||||||
|
|
||||||
GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte) -> string {
|
GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte) -> string {
|
||||||
@(default_calling_convention="c")
|
|
||||||
foreign webgl {
|
foreign webgl {
|
||||||
@(link_name="GetShaderInfoLog")
|
@(link_name="GetShaderInfoLog")
|
||||||
_GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte, length: ^int) ---
|
_GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte, length: ^int) ---
|
||||||
}
|
}
|
||||||
|
|
||||||
length: int
|
length: int
|
||||||
@@ -244,27 +241,27 @@ GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte) -> string {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
BufferDataSlice :: proc "c" (target: Enum, slice: $S/[]$E, usage: Enum) {
|
BufferDataSlice :: proc "contextless" (target: Enum, slice: $S/[]$E, usage: Enum) {
|
||||||
BufferData(target, len(slice)*size_of(E), raw_data(slice), usage)
|
BufferData(target, len(slice)*size_of(E), raw_data(slice), usage)
|
||||||
}
|
}
|
||||||
BufferSubDataSlice :: proc "c" (target: Enum, offset: uintptr, slice: $S/[]$E) {
|
BufferSubDataSlice :: proc "contextless" (target: Enum, offset: uintptr, slice: $S/[]$E) {
|
||||||
BufferSubData(target, offset, len(slice)*size_of(E), raw_data(slice), usage)
|
BufferSubData(target, offset, len(slice)*size_of(E), raw_data(slice), usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
CompressedTexImage2DSlice :: proc "c" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, slice: $S/[]$E) {
|
CompressedTexImage2DSlice :: proc "contextless" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, slice: $S/[]$E) {
|
||||||
CompressedTexImage2DSlice(target, level, internalformat, width, height, border, len(slice)*size_of(E), raw_data(slice))
|
CompressedTexImage2DSlice(target, level, internalformat, width, height, border, len(slice)*size_of(E), raw_data(slice))
|
||||||
}
|
}
|
||||||
CompressedTexSubImage2DSlice :: proc "c" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format: Enum, slice: $S/[]$E) {
|
CompressedTexSubImage2DSlice :: proc "contextless" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format: Enum, slice: $S/[]$E) {
|
||||||
CompressedTexSubImage2DSlice(target, level, level, xoffset, yoffset, width, height, format, len(slice)*size_of(E), raw_data(slice))
|
CompressedTexSubImage2DSlice(target, level, level, xoffset, yoffset, width, height, format, len(slice)*size_of(E), raw_data(slice))
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadPixelsSlice :: proc "c" (x, y, width, height: i32, format: Enum, type: Enum, slice: $S/[]$E) {
|
ReadPixelsSlice :: proc "contextless" (x, y, width, height: i32, format: Enum, type: Enum, slice: $S/[]$E) {
|
||||||
ReadnPixels(x, y, width, height, format, type, len(slice)*size_of(E), raw_data(slice))
|
ReadnPixels(x, y, width, height, format, type, len(slice)*size_of(E), raw_data(slice))
|
||||||
}
|
}
|
||||||
|
|
||||||
TexImage2DSlice :: proc "c" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, format, type: Enum, slice: $S/[]$E) {
|
TexImage2DSlice :: proc "contextless" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, format, type: Enum, slice: $S/[]$E) {
|
||||||
TexImage2D(target, level, internalformat, width, height, border, format, type, len(slice)*size_of(E), raw_data(slice))
|
TexImage2D(target, level, internalformat, width, height, border, format, type, len(slice)*size_of(E), raw_data(slice))
|
||||||
}
|
}
|
||||||
TexSubImage2DSlice :: proc "c" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format, type: Enum, slice: $S/[]$E) {
|
TexSubImage2DSlice :: proc "contextless" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format, type: Enum, slice: $S/[]$E) {
|
||||||
TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, len(slice)*size_of(E), raw_data(slice))
|
TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, len(slice)*size_of(E), raw_data(slice))
|
||||||
}
|
}
|
||||||
Vendored
+21
-21
@@ -10,13 +10,13 @@ Sync :: distinct u32
|
|||||||
TransformFeedback :: distinct u32
|
TransformFeedback :: distinct u32
|
||||||
VertexArrayObject :: distinct u32
|
VertexArrayObject :: distinct u32
|
||||||
|
|
||||||
IsWebGL2Supported :: proc "c" () -> bool {
|
IsWebGL2Supported :: proc "contextless" () -> bool {
|
||||||
major, minor: i32
|
major, minor: i32
|
||||||
GetWebGLVersion(&major, &minor)
|
GetWebGLVersion(&major, &minor)
|
||||||
return major >= 2
|
return major >= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@(default_calling_convention="c")
|
@(default_calling_convention="contextless")
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
/* Buffer objects */
|
/* Buffer objects */
|
||||||
CopyBufferSubData :: proc(readTarget, writeTarget: Enum, readOffset, writeOffset: int, size: int) ---
|
CopyBufferSubData :: proc(readTarget, writeTarget: Enum, readOffset, writeOffset: int, size: int) ---
|
||||||
@@ -110,7 +110,7 @@ foreign webgl2 {
|
|||||||
|
|
||||||
GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string {
|
GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) ---
|
_GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) ---
|
||||||
}
|
}
|
||||||
n: int
|
n: int
|
||||||
_GetActiveUniformBlockName(program, uniformBlockIndex, buf, &n)
|
_GetActiveUniformBlockName(program, uniformBlockIndex, buf, &n)
|
||||||
@@ -118,65 +118,65 @@ GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Uniform1uiv :: proc "c" (location: i32, v: u32) {
|
Uniform1uiv :: proc "contextless" (location: i32, v: u32) {
|
||||||
Uniform1ui(location, v)
|
Uniform1ui(location, v)
|
||||||
}
|
}
|
||||||
Uniform2uiv :: proc "c" (location: i32, v: glm.uvec2) {
|
Uniform2uiv :: proc "contextless" (location: i32, v: glm.uvec2) {
|
||||||
Uniform2ui(location, v.x, v.y)
|
Uniform2ui(location, v.x, v.y)
|
||||||
}
|
}
|
||||||
Uniform3uiv :: proc "c" (location: i32, v: glm.uvec3) {
|
Uniform3uiv :: proc "contextless" (location: i32, v: glm.uvec3) {
|
||||||
Uniform3ui(location, v.x, v.y, v.z)
|
Uniform3ui(location, v.x, v.y, v.z)
|
||||||
}
|
}
|
||||||
Uniform4uiv :: proc "c" (location: i32, v: glm.uvec4) {
|
Uniform4uiv :: proc "contextless" (location: i32, v: glm.uvec4) {
|
||||||
Uniform4ui(location, v.x, v.y, v.z, v.w)
|
Uniform4ui(location, v.x, v.y, v.z, v.w)
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformMatrix3x2fv :: proc "c" (location: i32, m: glm.mat3x2) {
|
UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix3x2fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix3x2fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix3x2fv(location, &array[0])
|
_UniformMatrix3x2fv(location, &array[0])
|
||||||
}
|
}
|
||||||
UniformMatrix4x2fv :: proc "c" (location: i32, m: glm.mat4x2) {
|
UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix4x2fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix4x2fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix4x2fv(location, &array[0])
|
_UniformMatrix4x2fv(location, &array[0])
|
||||||
}
|
}
|
||||||
UniformMatrix2x3fv :: proc "c" (location: i32, m: glm.mat2x3) {
|
UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix2x3fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix2x3fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix2x3fv(location, &array[0])
|
_UniformMatrix2x3fv(location, &array[0])
|
||||||
}
|
}
|
||||||
UniformMatrix4x3fv :: proc "c" (location: i32, m: glm.mat4x3) {
|
UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix4x3fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix4x3fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix4x3fv(location, &array[0])
|
_UniformMatrix4x3fv(location, &array[0])
|
||||||
}
|
}
|
||||||
UniformMatrix2x4fv :: proc "c" (location: i32, m: glm.mat2x4) {
|
UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix2x4fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix2x4fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix2x4fv(location, &array[0])
|
_UniformMatrix2x4fv(location, &array[0])
|
||||||
}
|
}
|
||||||
UniformMatrix3x4fv :: proc "c" (location: i32, m: glm.mat3x4) {
|
UniformMatrix3x4fv :: proc "contextless" (location: i32, m: glm.mat3x4) {
|
||||||
foreign webgl2 {
|
foreign webgl2 {
|
||||||
_UniformMatrix3x4fv :: proc "c" (location: i32, addr: [^]f32) ---
|
_UniformMatrix3x4fv :: proc "contextless" (location: i32, addr: [^]f32) ---
|
||||||
}
|
}
|
||||||
array := matrix_flatten(m)
|
array := matrix_flatten(m)
|
||||||
_UniformMatrix3x4fv(location, &array[0])
|
_UniformMatrix3x4fv(location, &array[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexAttribI4iv :: proc "c" (index: i32, v: glm.ivec4) {
|
VertexAttribI4iv :: proc "contextless" (index: i32, v: glm.ivec4) {
|
||||||
VertexAttribI4i(index, v.x, v.y, v.z, v.w)
|
VertexAttribI4i(index, v.x, v.y, v.z, v.w)
|
||||||
}
|
}
|
||||||
VertexAttribI4uiv :: proc "c" (index: i32, v: glm.uvec4) {
|
VertexAttribI4uiv :: proc "contextless" (index: i32, v: glm.uvec4) {
|
||||||
VertexAttribI4ui(index, v.x, v.y, v.z, v.w)
|
VertexAttribI4ui(index, v.x, v.y, v.z, v.w)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user