Skip to content

Commit

Permalink
Rename to odin-wasm and add comments to copied odin files
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Jan 12, 2024
1 parent 02492fc commit cd08ba1
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 30 deletions.
1 change: 0 additions & 1 deletion example/main.odin
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//+build js
package main

import "../wasm"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tsodin",
"name": "odin-wasm",
"author": "Damian Tarnawski <[email protected]>",
"license": "MIT",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tsodin
# Odin WASM

For using Odin, wasm and typescript.
For using Odin and WASM together.

## Development

Expand Down
7 changes: 7 additions & 0 deletions wasm/dom/dom_all_targets.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build !js
package wasm_js_interface

Expand Down
7 changes: 7 additions & 0 deletions wasm/dom/dom_js.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build js wasm32, js wasm64p32
package wasm_js_interface

Expand Down
7 changes: 7 additions & 0 deletions wasm/dom/events_all_targets.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build !js
package wasm_js_interface

Expand Down
7 changes: 7 additions & 0 deletions wasm/dom/events_js.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build js wasm32, js wasm64p32
package wasm_js_interface

Expand Down
7 changes: 7 additions & 0 deletions wasm/env_js.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build js
package wasm

Expand Down
7 changes: 7 additions & 0 deletions wasm/memory_all_targets.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build !js
package wasm

Expand Down
7 changes: 7 additions & 0 deletions wasm/memory_js.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

//+build js wasm32, js wasm64p32
package wasm

Expand Down
59 changes: 33 additions & 26 deletions wasm/webgl/webgl.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

package webgl

foreign import "webgl"
Expand Down Expand Up @@ -38,12 +45,12 @@ foreign webgl {

DrawingBufferWidth :: proc() -> i32 ---
DrawingBufferHeight :: proc() -> i32 ---

GetWebGLVersion :: proc(major, minor: ^i32) ---
GetESVersion :: proc(major, minor: ^i32) ---

GetError :: proc() -> Enum ---

IsExtensionSupported :: proc(name: string) -> bool ---

ActiveTexture :: proc(x: Enum) ---
Expand All @@ -56,7 +63,7 @@ foreign webgl {
BlendEquation :: proc(mode: Enum) ---
BlendFunc :: proc(sfactor, dfactor: Enum) ---
BlendFuncSeparate :: proc(srcRGB, dstRGB, srcAlpha, dstAlpha: Enum) ---

BufferData :: proc(target: Enum, size: int, data: rawptr, usage: Enum) ---
BufferSubData :: proc(target: Enum, offset: uintptr, size: int, data: rawptr) ---

Expand All @@ -66,29 +73,29 @@ foreign webgl {
ClearStencil :: proc(x: Enum) ---
ClearMask :: proc(r, g, b, a: bool) ---
CompileShader :: proc(shader: Shader) ---

CompressedTexImage2D :: proc(target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, imageSize: int, data: rawptr) ---
CompressedTexSubImage2D :: proc(target: Enum, level: i32, xoffset, yoffset, width, height: i32, format: Enum, imageSize: int, data: rawptr) ---
CopyTexImage2D :: proc(target: Enum, level: i32, internalformat: Enum, x, y, width, height: i32, border: i32) ---
CopyTexSubImage2D :: proc(target: Enum, level: i32, xoffset, yoffset, x, y: i32, width, height: i32) ---


CreateBuffer :: proc() -> Buffer ---
CreateFramebuffer :: proc() -> Framebuffer ---
CreateProgram :: proc() -> Program ---
CreateRenderbuffer :: proc() -> Renderbuffer ---
CreateShader :: proc(shaderType: Enum) -> Shader ---
CreateTexture :: proc() -> Texture ---

CullFace :: proc(mode: Enum) ---

DeleteBuffer :: proc(buffer: Buffer) ---
DeleteFramebuffer :: proc(framebuffer: Framebuffer) ---
DeleteProgram :: proc(program: Program) ---
DeleteRenderbuffer :: proc(renderbuffer: Renderbuffer) ---
DeleteShader :: proc(shader: Shader) ---
DeleteTexture :: proc(texture: Texture) ---

DepthFunc :: proc(func: Enum) ---
DepthMask :: proc(flag: bool) ---
DepthRange :: proc(zNear, zFar: f32) ---
Expand All @@ -97,76 +104,76 @@ foreign webgl {
DisableVertexAttribArray :: proc(index: i32) ---
DrawArrays :: proc(mode: Enum, first, count: int) ---
DrawElements :: proc(mode: Enum, count: int, type: Enum, indices: rawptr) ---

Enable :: proc(cap: Enum) ---
EnableVertexAttribArray :: proc(index: i32) ---
Finish :: proc() ---
Flush :: proc() ---
FramebufferRenderbuffer :: proc(target, attachment, renderbufertarget: Enum, renderbuffer: Renderbuffer) ---
FramebufferTexture2D :: proc(target, attachment, textarget: Enum, texture: Texture, level: i32) ---
FrontFace :: proc(mode: Enum) ---

GenerateMipmap :: proc(target: Enum) ---

GetAttribLocation :: proc(program: Program, name: string) -> i32 ---
GetUniformLocation :: proc(program: Program, name: string) -> i32 ---
GetVertexAttribOffset :: proc(index: i32, pname: Enum) -> uintptr ---
GetProgramParameter :: proc(program: Program, pname: Enum) -> i32 ---
GetParameter :: proc(pname: Enum) -> i32 ---

Hint :: proc(target: Enum, mode: Enum) ---

IsBuffer :: proc(buffer: Buffer) -> bool ---
IsEnabled :: proc(cap: Enum) -> bool ---
IsFramebuffer :: proc(framebuffer: Framebuffer) -> bool ---
IsProgram :: proc(program: Program) -> bool ---
IsRenderbuffer :: proc(renderbuffer: Renderbuffer) -> bool ---
IsShader :: proc(shader: Shader) -> bool ---
IsTexture :: proc(texture: Texture) -> bool ---

LineWidth :: proc(width: f32) ---
LinkProgram :: proc(program: Program) ---
PixelStorei :: proc(pname: Enum, param: i32) ---
PolygonOffset :: proc(factor: f32, units: f32) ---

ReadnPixels :: proc(x, y, width, height: i32, format: Enum, type: Enum, bufSize: int, data: rawptr) ---
RenderbufferStorage :: proc(target: Enum, internalformat: Enum, width, height: i32) ---
SampleCoverage :: proc(value: f32, invert: bool) ---
Scissor :: proc(x, y, width, height: i32) ---
ShaderSource :: proc(shader: Shader, strings: []string) ---

StencilFunc :: proc(func: Enum, ref: i32, mask: u32) ---
StencilFuncSeparate :: proc(face, func: Enum, ref: i32, mask: u32) ---
StencilMask :: proc(mask: u32) ---
StencilMaskSeparate :: proc(face: Enum, mask: u32) ---
StencilOp :: proc(fail, zfail, zpass: Enum) ---
StencilOpSeparate :: proc(face, fail, zfail, zpass: Enum) ---

TexImage2D :: proc(target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, format, type: Enum, size: int, data: rawptr) ---
TexSubImage2D :: proc(target: Enum, level: i32, xoffset, yoffset, width, height: i32, format, type: Enum, size: int, data: rawptr) ---

TexParameterf :: proc(target, pname: Enum, param: f32) ---
TexParameteri :: proc(target, pname: Enum, param: i32) ---

Uniform1f :: proc(location: i32, v0: f32) ---
Uniform2f :: proc(location: i32, v0, v1: f32) ---
Uniform3f :: proc(location: i32, v0, v1, v2: f32) ---
Uniform4f :: proc(location: i32, v0, v1, v2, v3: f32) ---

Uniform1i :: proc(location: i32, v0: i32) ---
Uniform2i :: proc(location: i32, v0, v1: i32) ---
Uniform3i :: proc(location: i32, v0, v1, v2: i32) ---
Uniform4i :: proc(location: i32, v0, v1, v2, v3: i32) ---

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

VertexAttrib1f :: proc(index: i32, x: f32) ---
VertexAttrib2f :: proc(index: i32, x, y: f32) ---
VertexAttrib3f :: proc(index: i32, x, y, z: f32) ---
VertexAttrib4f :: proc(index: i32, x, y, z, w: f32) ---
VertexAttribPointer :: proc(index: i32, size: int, type: Enum, normalized: bool, stride: int, ptr: uintptr) ---

Viewport :: proc(x, y, w, h: i32) ---
}

Expand Down Expand Up @@ -224,7 +231,7 @@ GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte) -> strin
@(link_name="GetProgramInfoLog")
_GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte, length: ^int) ---
}

length: int
_GetProgramInfoLog(program, buf, &length)
return string(buf[:length])
Expand All @@ -235,7 +242,7 @@ GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte) -> string {
@(link_name="GetShaderInfoLog")
_GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte, length: ^int) ---
}

length: int
_GetShaderInfoLog(shader, buf, &length)
return string(buf[:length])
Expand Down Expand Up @@ -266,4 +273,4 @@ TexImage2DSlice :: proc "contextless" (target: Enum, level: i32, internalformat:
}
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))
}
}
7 changes: 7 additions & 0 deletions wasm/webgl/webgl2.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

package webgl

foreign import "webgl2"
Expand Down
7 changes: 7 additions & 0 deletions wasm/webgl/webgl2_constants.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

package webgl

READ_BUFFER :: Enum(0x0C02)
Expand Down
7 changes: 7 additions & 0 deletions wasm/webgl/webgl_constants.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

package webgl

/* ClearBufferMask */
Expand Down
7 changes: 7 additions & 0 deletions wasm/webgl/webgl_helpers.odin
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Copied from the Odin/vendor/wasm
https://github.com/odin-lang/Odin/tree/master/vendor/wasm
*/

package webgl

import "core:fmt"
Expand Down

0 comments on commit cd08ba1

Please sign in to comment.