mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
wasm: support more vendor libraries
Adds support for: - box2d - cgltf - stb image - stb rect pack
This commit is contained in:
+16
-6
@@ -7,6 +7,7 @@ WRITE_LIB :: (
|
||||
"../lib/stb_image_write.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_image_write.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_image_write.a" when ODIN_OS == .Darwin
|
||||
else "../lib/stb_image_write_wasm.o" when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32
|
||||
else ""
|
||||
)
|
||||
|
||||
@@ -15,7 +16,11 @@ when WRITE_LIB != "" {
|
||||
// The STB libraries are shipped with the compiler on Windows so a Windows specific message should not be needed.
|
||||
#panic("Could not find the compiled STB libraries, they can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/stb/src\"`")
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
||||
foreign import stbiw "../lib/stb_image_write_wasm.o"
|
||||
} else when WRITE_LIB != "" {
|
||||
foreign import stbiw { WRITE_LIB }
|
||||
} else {
|
||||
foreign import stbiw "system:stb_image_write"
|
||||
@@ -25,12 +30,6 @@ write_func :: proc "c" (ctx: rawptr, data: rawptr, size: c.int)
|
||||
|
||||
@(default_calling_convention="c", link_prefix="stbi_")
|
||||
foreign stbiw {
|
||||
write_png :: proc(filename: cstring, w, h, comp: c.int, data: rawptr, stride_in_bytes: c.int) -> c.int ---
|
||||
write_bmp :: proc(filename: cstring, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
write_tga :: proc(filename: cstring, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
write_hdr :: proc(filename: cstring, w, h, comp: c.int, data: [^]f32) -> c.int ---
|
||||
write_jpg :: proc(filename: cstring, w, h, comp: c.int, data: rawptr, quality: c.int /*0..=100*/) -> c.int ---
|
||||
|
||||
write_png_to_func :: proc(func: write_func, ctx: rawptr, w, h, comp: c.int, data: rawptr, stride_in_bytes: c.int) -> c.int ---
|
||||
write_bmp_to_func :: proc(func: write_func, ctx: rawptr, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
write_tga_to_func :: proc(func: write_func, ctx: rawptr, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
@@ -39,3 +38,14 @@ foreign stbiw {
|
||||
|
||||
flip_vertically_on_write :: proc(flip_boolean: b32) ---
|
||||
}
|
||||
|
||||
when !NO_STDIO {
|
||||
@(default_calling_convention="c", link_prefix="stbi_")
|
||||
foreign stbiw {
|
||||
write_png :: proc(filename: cstring, w, h, comp: c.int, data: rawptr, stride_in_bytes: c.int) -> c.int ---
|
||||
write_bmp :: proc(filename: cstring, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
write_tga :: proc(filename: cstring, w, h, comp: c.int, data: rawptr) -> c.int ---
|
||||
write_hdr :: proc(filename: cstring, w, h, comp: c.int, data: [^]f32) -> c.int ---
|
||||
write_jpg :: proc(filename: cstring, w, h, comp: c.int, data: rawptr, quality: c.int /*0..=100*/) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user