mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Merge remote-tracking branch 'offical/master'
This commit is contained in:
Vendored
+18
-4
@@ -1,9 +1,23 @@
|
||||
package cgltf
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/cgltf.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import lib "lib/cgltf.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import lib "lib/darwin/cgltf.a" }
|
||||
else { foreign import lib "system:cgltf" }
|
||||
@(private)
|
||||
LIB :: (
|
||||
"lib/cgltf.lib" when ODIN_OS == .Windows
|
||||
else "lib/cgltf.a" when ODIN_OS == .Linux
|
||||
else "lib/darwin/cgltf.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when LIB != "" {
|
||||
when !#exists(LIB) {
|
||||
// Windows library is shipped with the compiler, so a Windows specific message should not be needed.
|
||||
#panic("Could not find the compiled cgltf library, it can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/cgltf/src\"`")
|
||||
}
|
||||
|
||||
foreign import lib { LIB }
|
||||
} else {
|
||||
foreign import lib "system:cgltf"
|
||||
}
|
||||
|
||||
import "core:c"
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3374,7 +3374,7 @@ CREATE_DEVICE_FLAG :: enum u32 {
|
||||
DEBUGGABLE = 6,
|
||||
PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY = 7,
|
||||
DISABLE_GPU_TIMEOUT = 8,
|
||||
VIDEO_SUPPORT = 12,
|
||||
VIDEO_SUPPORT = 11,
|
||||
}
|
||||
|
||||
PFN_CREATE_DEVICE :: #type proc "c" (a0: ^dxgi.IAdapter, a1: DRIVER_TYPE, a2: HMODULE, a3: u32, a4: ^FEATURE_LEVEL, a5: u32, a6: u32, a7: ^^IDevice, a8: ^FEATURE_LEVEL, a9: ^^IDeviceContext) -> HRESULT
|
||||
|
||||
Vendored
+1
-1
@@ -47,7 +47,7 @@ foreign egl {
|
||||
GetDisplay :: proc(display: NativeDisplayType) -> Display ---
|
||||
Initialize :: proc(display: Display, major: ^i32, minor: ^i32) -> i32 ---
|
||||
BindAPI :: proc(api: u32) -> i32 ---
|
||||
ChooseConfig :: proc(display: Display, attrib_list: ^i32, configs: ^Context, config_size: i32, num_config: ^i32) -> i32 ---
|
||||
ChooseConfig :: proc(display: Display, attrib_list: ^i32, configs: ^Config, config_size: i32, num_config: ^i32) -> i32 ---
|
||||
CreateWindowSurface :: proc(display: Display, config: Config, native_window: NativeWindowType, attrib_list: ^i32) -> Surface ---
|
||||
CreateContext :: proc(display: Display, config: Config, share_context: Context, attrib_list: ^i32) -> Context ---
|
||||
MakeCurrent :: proc(display: Display, draw: Surface, read: Surface, ctx: Context) -> i32 ---
|
||||
|
||||
Vendored
+8
-4
@@ -8,12 +8,16 @@ when MINIAUDIO_SHARED {
|
||||
#panic("Shared linking for miniaudio is not supported yet")
|
||||
}
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
@(private)
|
||||
LIB :: "lib/miniaudio.lib" when ODIN_OS == .Windows else "lib/miniaudio.a"
|
||||
|
||||
when !#exists(LIB) {
|
||||
// Windows library is shipped with the compiler, so a Windows specific message should not be needed.
|
||||
#panic("Could not find the compiled miniaudio library, it can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/miniaudio/src\"`")
|
||||
}
|
||||
|
||||
foreign import lib { LIB }
|
||||
|
||||
BINDINGS_VERSION_MAJOR :: 0
|
||||
BINDINGS_VERSION_MINOR :: 11
|
||||
BINDINGS_VERSION_REVISION :: 21
|
||||
|
||||
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
*************************************************************************************************************************************************************
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
+1
-5
@@ -1,10 +1,6 @@
|
||||
package miniaudio
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
import "core:c"
|
||||
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/*
|
||||
Delay
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/**************************************************************************************************************************************************************
|
||||
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
waveform_type :: enum c.int {
|
||||
sine,
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/*
|
||||
Slot Allocator
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c/libc"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
MAX_LOG_CALLBACKS :: 4
|
||||
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
+1
-5
@@ -1,10 +1,6 @@
|
||||
package miniaudio
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
@(default_calling_convention="c", link_prefix="ma_")
|
||||
foreign lib {
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
@(default_calling_convention="c", link_prefix="ma_")
|
||||
foreign lib {
|
||||
|
||||
Vendored
+1
-5
@@ -2,11 +2,7 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
}
|
||||
foreign import lib { LIB }
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
Vendored
+17
-43
@@ -5,47 +5,21 @@ import "core:c"
|
||||
RAYGUI_SHARED :: #config(RAYGUI_SHARED, true)
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
when RAYGUI_SHARED {
|
||||
foreign import lib {
|
||||
"windows/rayguidll.lib",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"windows/raygui.lib",
|
||||
}
|
||||
foreign import lib {
|
||||
"windows/rayguidll.lib" when RAYGUI_SHARED else "windows/raygui.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
when RAYGUI_SHARED {
|
||||
foreign import lib "linux/libraygui.so"
|
||||
} else {
|
||||
foreign import lib "linux/libraygui.a"
|
||||
foreign import lib {
|
||||
"linux/libraygui.so" when RAYGUI_SHARED else "linux/libraygui.a",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
when RAYGUI_SHARED {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraygui.dylib",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraygui.a",
|
||||
// "system:Cocoa.framework",
|
||||
// "system:OpenGL.framework",
|
||||
// "system:IOKit.framework",
|
||||
}
|
||||
foreign import lib {
|
||||
"macos-arm64/libraygui.dylib" when RAYGUI_SHARED else "macos-arm64/libraygui.a",
|
||||
}
|
||||
} else {
|
||||
when RAYGUI_SHARED {
|
||||
foreign import lib {
|
||||
"macos/libraygui.dylib",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos/libraygui.a",
|
||||
// "system:Cocoa.framework",
|
||||
// "system:OpenGL.framework",
|
||||
// "system:IOKit.framework",
|
||||
}
|
||||
foreign import lib {
|
||||
"macos/libraygui.dylib" when RAYGUI_SHARED else "macos/libraygui.a",
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -56,8 +30,8 @@ RAYGUI_VERSION :: "4.0"
|
||||
|
||||
// Style property
|
||||
GuiStyleProp :: struct {
|
||||
controlId: u16,
|
||||
propertyId: u16,
|
||||
controlId: u16,
|
||||
propertyId: u16,
|
||||
propertyValue: c.int,
|
||||
}
|
||||
|
||||
@@ -226,7 +200,7 @@ GuiColorPickerProperty :: enum c.int {
|
||||
HUEBAR_SELECTOR_OVERFLOW, // ColorPicker right hue bar selector overflow
|
||||
}
|
||||
|
||||
SCROLLBAR_LEFT_SIDE :: 0
|
||||
SCROLLBAR_LEFT_SIDE :: 0
|
||||
SCROLLBAR_RIGHT_SIDE :: 1
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -262,8 +236,8 @@ foreign lib {
|
||||
|
||||
// Style set/get functions
|
||||
|
||||
GuiSetStyle :: proc(control: c.int, property: c.int, value: c.int) --- // Set one style property
|
||||
GuiGetStyle :: proc(control: c.int, property: c.int) -> c.int --- // Get one style property
|
||||
GuiSetStyle :: proc(control: GuiControl, property: GuiStyleProp, value: c.int) --- // Set one style property
|
||||
GuiGetStyle :: proc(control: GuiControl, property: GuiStyleProp) -> c.int --- // Get one style property
|
||||
|
||||
// Styles loading functions
|
||||
|
||||
@@ -278,11 +252,11 @@ foreign lib {
|
||||
|
||||
// Icons functionality
|
||||
|
||||
GuiIconText :: proc(iconId: c.int, text: cstring) -> cstring --- // Get text with icon id prepended (if supported)
|
||||
GuiIconText :: proc(iconId: GuiIconName, text: cstring) -> cstring --- // Get text with icon id prepended (if supported)
|
||||
GuiSetIconScale :: proc(scale: c.int) --- // Set default icon drawing size
|
||||
GuiGetIcons :: proc() -> [^]u32 --- // Get raygui icons data pointer
|
||||
GuiLoadIcons :: proc(fileName: cstring, loadIconsName: bool) -> [^]cstring --- // Load raygui icons file (.rgi) into internal icons data
|
||||
GuiDrawIcon :: proc(iconId: c.int, posX: c.int, posY: c.int, pixelSize: c.int, color: Color) --- // Draw icon using pixel size at specified position
|
||||
GuiDrawIcon :: proc(iconId: GuiIconName, posX, posY: c.int, pixelSize: c.int, color: Color) --- // Draw icon using pixel size at specified position
|
||||
|
||||
|
||||
// Controls
|
||||
@@ -300,11 +274,11 @@ foreign lib {
|
||||
|
||||
GuiLabel :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Label control, shows text
|
||||
GuiButton :: proc(bounds: Rectangle, text: cstring) -> bool --- // Button control, returns true when clicked
|
||||
GuiLabelButton :: proc(bounds: Rectangle, text: cstring) -> bool --- // Label button control, show true when clicked
|
||||
GuiLabelButton :: proc(bounds: Rectangle, text: cstring) -> bool --- // Label button control, show true when clicked
|
||||
GuiToggle :: proc(bounds: Rectangle, text: cstring, active: ^bool) -> c.int --- // Toggle Button control, returns true when active
|
||||
GuiToggleGroup :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int --- // Toggle Group control, returns active toggle index
|
||||
GuiToggleSlider :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int ---
|
||||
GuiCheckBox :: proc(bounds: Rectangle, text: cstring, checked: ^bool) -> bool --- // Check Box control, returns true when active
|
||||
GuiCheckBox :: proc(bounds: Rectangle, text: cstring, checked: ^bool) -> bool --- // Check Box control, returns true when active
|
||||
GuiComboBox :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int --- // Combo Box control, returns selected item index
|
||||
|
||||
GuiDropdownBox :: proc(bounds: Rectangle, text: cstring, active: ^c.int, editMode: bool) -> bool --- // Dropdown Box control, returns selected item
|
||||
|
||||
Vendored
+24
-68
@@ -97,76 +97,32 @@ MAX_TEXT_BUFFER_LENGTH :: #config(RAYLIB_MAX_TEXT_BUFFER_LENGTH, 1024)
|
||||
RAYLIB_SHARED :: #config(RAYLIB_SHARED, true)
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
when RAYLIB_SHARED {
|
||||
@(extra_linker_flags="/NODEFAULTLIB:msvcrt")
|
||||
foreign import lib {
|
||||
"windows/raylibdll.lib",
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
} else {
|
||||
@(extra_linker_flags="/NODEFAULTLIB:libcmt")
|
||||
foreign import lib {
|
||||
"windows/raylib.lib",
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
|
||||
foreign import lib {
|
||||
"windows/raylibdll.lib" when RAYLIB_SHARED else "windows/raylib.lib" ,
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
when RAYLIB_SHARED {
|
||||
foreign import lib {
|
||||
// Note(bumbread): I'm not sure why in `linux/` folder there are
|
||||
// multiple copies of raylib.so, but since these bindings are for
|
||||
// particular version of the library, I better specify it. Ideally,
|
||||
// though, it's best specified in terms of major (.so.4)
|
||||
"linux/libraylib.so.500",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"linux/libraylib.a",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
foreign import lib {
|
||||
// Note(bumbread): I'm not sure why in `linux/` folder there are
|
||||
// multiple copies of raylib.so, but since these bindings are for
|
||||
// particular version of the library, I better specify it. Ideally,
|
||||
// though, it's best specified in terms of major (.so.4)
|
||||
"linux/libraylib.so.500" when RAYLIB_SHARED else "linux/libraylib.a",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
when RAYLIB_SHARED {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraylib.500.dylib",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when RAYLIB_SHARED {
|
||||
foreign import lib {
|
||||
"macos/libraylib.500.dylib",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
}
|
||||
foreign import lib {
|
||||
"macos" +
|
||||
"-arm64" when ODIN_ARCH == .arm64 else "" +
|
||||
"/libraylib" + ".500.dylib" when RAYLIB_SHARED else ".a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else {
|
||||
foreign import lib "system:raylib"
|
||||
@@ -951,8 +907,8 @@ foreign lib {
|
||||
SetWindowTitle :: proc(title: cstring) --- // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
SetWindowPosition :: proc(x, y: c.int) --- // Set window position on screen (only PLATFORM_DESKTOP)
|
||||
SetWindowMonitor :: proc(monitor: c.int) --- // Set monitor for the current window
|
||||
SetWindowMinSize :: proc(width, height: c.int) --- // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||
SetWindowMaxSize :: proc(width, height: c.int) --- // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||
SetWindowMinSize :: proc(width, height: c.int) --- // Set window minimum dimensions (for WINDOW_RESIZABLE)
|
||||
SetWindowMaxSize :: proc(width, height: c.int) --- // Set window maximum dimensions (for WINDOW_RESIZABLE)
|
||||
SetWindowSize :: proc(width, height: c.int) --- // Set window dimensions
|
||||
SetWindowOpacity :: proc(opacity: f32) --- // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
||||
SetWindowFocused :: proc() --- // Set window focused (only PLATFORM_DESKTOP)
|
||||
|
||||
Vendored
+5
-14
@@ -122,20 +122,11 @@ when ODIN_OS == .Windows {
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "linux/libraylib.a"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
foreign import lib {
|
||||
"macos-arm64/libraylib.a" when ODIN_ARCH == .arm64 else "macos/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else {
|
||||
foreign import lib "system:raylib"
|
||||
|
||||
Vendored
+19
-6
@@ -2,13 +2,26 @@ package stb_image
|
||||
|
||||
import c "core:c/libc"
|
||||
|
||||
@(private)
|
||||
LIB :: (
|
||||
"../lib/stb_image.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_image.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_image.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when LIB != "" {
|
||||
when !#exists(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\"`")
|
||||
}
|
||||
|
||||
foreign import stbi { LIB }
|
||||
} else {
|
||||
foreign import stbi "system:stb_image"
|
||||
}
|
||||
|
||||
#assert(size_of(c.int) == size_of(b32))
|
||||
|
||||
when ODIN_OS == .Windows { foreign import stbi "../lib/stb_image.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import stbi "../lib/stb_image.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import stbi "../lib/darwin/stb_image.a" }
|
||||
else { foreign import stbi "system:stb_image" }
|
||||
|
||||
#assert(size_of(b32) == size_of(c.int))
|
||||
|
||||
//
|
||||
|
||||
+17
-4
@@ -2,11 +2,24 @@ package stb_image
|
||||
|
||||
import c "core:c/libc"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "../lib/stb_image_resize.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import lib "../lib/stb_image_resize.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import lib "../lib/darwin/stb_image_resize.a" }
|
||||
else { foreign import lib "system:stb_image_resize" }
|
||||
@(private)
|
||||
RESIZE_LIB :: (
|
||||
"../lib/stb_image_resize.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_image_resize.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_image_resize.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when RESIZE_LIB != "" {
|
||||
when !#exists(RESIZE_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\"`")
|
||||
}
|
||||
|
||||
foreign import lib { RESIZE_LIB }
|
||||
} else {
|
||||
foreign import lib "system:stb_image_resize"
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
+17
-4
@@ -2,11 +2,24 @@ package stb_image
|
||||
|
||||
import c "core:c/libc"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import stbiw "../lib/stb_image_write.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import stbiw "../lib/stb_image_write.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import stbiw "../lib/darwin/stb_image_write.a" }
|
||||
else { foreign import stbiw "system:stb_image_write" }
|
||||
@(private)
|
||||
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 ""
|
||||
)
|
||||
|
||||
when WRITE_LIB != "" {
|
||||
when !#exists(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\"`")
|
||||
}
|
||||
|
||||
foreign import stbiw { WRITE_LIB }
|
||||
} else {
|
||||
foreign import stbiw "system:stb_image_write"
|
||||
}
|
||||
|
||||
write_func :: proc "c" (ctx: rawptr, data: rawptr, size: c.int)
|
||||
|
||||
|
||||
+17
-4
@@ -4,10 +4,23 @@ import "core:c"
|
||||
|
||||
#assert(size_of(b32) == size_of(c.int))
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "../lib/stb_rect_pack.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import lib "../lib/stb_rect_pack.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import lib "../lib/darwin/stb_rect_pack.a" }
|
||||
else { foreign import lib "system:stb_rect_pack" }
|
||||
@(private)
|
||||
LIB :: (
|
||||
"../lib/stb_rect_pack.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_rect_pack.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_rect_pack.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when LIB != "" {
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled STB libraries, they can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/stb/src\"`")
|
||||
}
|
||||
|
||||
foreign import lib { LIB }
|
||||
} else {
|
||||
foreign import lib "system:stb_rect_pack"
|
||||
}
|
||||
|
||||
Coord :: distinct c.int
|
||||
_MAXVAL :: max(Coord)
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ unix:
|
||||
$(AR) rcs ../lib/stb_image_resize.a stb_image_resize.o
|
||||
$(AR) rcs ../lib/stb_truetype.a stb_truetype.o
|
||||
$(AR) rcs ../lib/stb_rect_pack.a stb_rect_pack.o
|
||||
#$(AR) rcs ../lib/stb_vorbis_pack.a stb_vorbis_pack.o
|
||||
$(AR) rcs ../lib/stb_vorbis.a stb_vorbis.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image.so -o ../lib/stb_image.so stb_image.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image_write.so -o ../lib/stb_image_write.so stb_image_write.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image_resize.so -o ../lib/stb_image_resize.so stb_image_resize.o
|
||||
|
||||
+16
-4
@@ -3,11 +3,23 @@ package stb_truetype
|
||||
import c "core:c"
|
||||
import stbrp "vendor:stb/rect_pack"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import stbtt "../lib/stb_truetype.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import stbtt "../lib/stb_truetype.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import stbtt "../lib/darwin/stb_truetype.a" }
|
||||
else { foreign import stbtt "system:stb_truetype" }
|
||||
@(private)
|
||||
LIB :: (
|
||||
"../lib/stb_truetype.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_truetype.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_truetype.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when LIB != "" {
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled STB libraries, they can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/stb/src\"`")
|
||||
}
|
||||
|
||||
foreign import stbtt { LIB }
|
||||
} else {
|
||||
foreign import stbtt "system:stb_truetype"
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+15
-5
@@ -2,13 +2,23 @@ package stb_vorbis
|
||||
|
||||
import c "core:c/libc"
|
||||
|
||||
@(private)
|
||||
LIB :: (
|
||||
"../lib/stb_vorbis.lib" when ODIN_OS == .Windows
|
||||
else "../lib/stb_vorbis.a" when ODIN_OS == .Linux
|
||||
else "../lib/darwin/stb_vorbis.a" when ODIN_OS == .Darwin
|
||||
else ""
|
||||
)
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "../lib/stb_vorbis.lib" }
|
||||
else when ODIN_OS == .Linux { foreign import lib "../lib/stb_vorbis.a" }
|
||||
else when ODIN_OS == .Darwin { foreign import lib "../lib/darwin/stb_vorbis.a" }
|
||||
else { foreign import lib "system:stb_vorbis" }
|
||||
|
||||
when LIB != "" {
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled STB libraries, they can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/stb/src\"`")
|
||||
}
|
||||
|
||||
foreign import lib { LIB }
|
||||
} else {
|
||||
foreign import lib "system:stb_vorbis"
|
||||
}
|
||||
|
||||
/////////// THREAD SAFETY
|
||||
|
||||
|
||||
Vendored
+64
-30
@@ -13,14 +13,18 @@ function stripNewline(str) {
|
||||
return str.replace(/\n/, ' ')
|
||||
}
|
||||
|
||||
const INT_SIZE = 4; // NOTE: set to `8` if the target has 64 bit ints (`wasm64p32` for example).
|
||||
const STRING_SIZE = 2*INT_SIZE;
|
||||
|
||||
class WasmMemoryInterface {
|
||||
constructor() {
|
||||
this.memory = null;
|
||||
this.exports = null;
|
||||
this.listenerMap = {};
|
||||
|
||||
// Size (in bytes) of the integer type, should be 4 on `js_wasm32` and 8 on `js_wasm64p32`
|
||||
this.intSize = 4;
|
||||
}
|
||||
|
||||
setIntSize(size) {
|
||||
this.intSize = size;
|
||||
}
|
||||
|
||||
setMemory(memory) {
|
||||
@@ -73,21 +77,21 @@ class WasmMemoryInterface {
|
||||
loadF32(addr) { return this.mem.getFloat32(addr, true); }
|
||||
loadF64(addr) { return this.mem.getFloat64(addr, true); }
|
||||
loadInt(addr) {
|
||||
if (INT_SIZE == 8) {
|
||||
if (this.intSize == 8) {
|
||||
return this.loadI64(addr);
|
||||
} else if (INT_SIZE == 4) {
|
||||
} else if (this.intSize == 4) {
|
||||
return this.loadI32(addr);
|
||||
} else {
|
||||
throw new Error('Unhandled `INT_SIZE`, expected `4` or `8`');
|
||||
throw new Error('Unhandled `intSize`, expected `4` or `8`');
|
||||
}
|
||||
};
|
||||
loadUint(addr) {
|
||||
if (INT_SIZE == 8) {
|
||||
if (this.intSize == 8) {
|
||||
return this.loadU64(addr);
|
||||
} else if (INT_SIZE == 4) {
|
||||
} else if (this.intSize == 4) {
|
||||
return this.loadU32(addr);
|
||||
} else {
|
||||
throw new Error('Unhandled `INT_SIZE`, expected `4` or `8`');
|
||||
throw new Error('Unhandled `intSize`, expected `4` or `8`');
|
||||
}
|
||||
};
|
||||
loadPtr(addr) { return this.loadU32(addr); }
|
||||
@@ -108,31 +112,43 @@ class WasmMemoryInterface {
|
||||
storeU32(addr, value) { this.mem.setUint32 (addr, value, true); }
|
||||
storeI32(addr, value) { this.mem.setInt32 (addr, value, true); }
|
||||
storeU64(addr, value) {
|
||||
this.mem.setUint32(addr + 0, value, true);
|
||||
this.mem.setUint32(addr + 4, Math.floor(value / 4294967296), true);
|
||||
this.mem.setUint32(addr + 0, Number(value), true);
|
||||
|
||||
let div = 4294967296;
|
||||
if (typeof value == 'bigint') {
|
||||
div = BigInt(div);
|
||||
}
|
||||
|
||||
this.mem.setUint32(addr + 4, Math.floor(Number(value / div)), true);
|
||||
}
|
||||
storeI64(addr, value) {
|
||||
this.mem.setUint32(addr + 0, value, true);
|
||||
this.mem.setInt32 (addr + 4, Math.floor(value / 4294967296), true);
|
||||
this.mem.setUint32(addr + 0, Number(value), true);
|
||||
|
||||
let div = 4294967296;
|
||||
if (typeof value == 'bigint') {
|
||||
div = BigInt(div);
|
||||
}
|
||||
|
||||
this.mem.setInt32(addr + 4, Math.floor(Number(value / div)), true);
|
||||
}
|
||||
storeF32(addr, value) { this.mem.setFloat32(addr, value, true); }
|
||||
storeF64(addr, value) { this.mem.setFloat64(addr, value, true); }
|
||||
storeInt(addr, value) {
|
||||
if (INT_SIZE == 8) {
|
||||
if (this.intSize == 8) {
|
||||
this.storeI64(addr, value);
|
||||
} else if (INT_SIZE == 4) {
|
||||
} else if (this.intSize == 4) {
|
||||
this.storeI32(addr, value);
|
||||
} else {
|
||||
throw new Error('Unhandled `INT_SIZE`, expected `4` or `8`');
|
||||
throw new Error('Unhandled `intSize`, expected `4` or `8`');
|
||||
}
|
||||
}
|
||||
storeUint(addr, value) {
|
||||
if (INT_SIZE == 8) {
|
||||
if (this.intSize == 8) {
|
||||
this.storeU64(addr, value);
|
||||
} else if (INT_SIZE == 4) {
|
||||
} else if (this.intSize == 4) {
|
||||
this.storeU32(addr, value);
|
||||
} else {
|
||||
throw new Error('Unhandled `INT_SIZE`, expected `4` or `8`');
|
||||
throw new Error('Unhandled `intSize`, expected `4` or `8`');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,10 +257,11 @@ class WebGLInterface {
|
||||
}
|
||||
}
|
||||
getSource(shader, strings_ptr, strings_length) {
|
||||
const stringSize = this.mem.intSize*2;
|
||||
let source = "";
|
||||
for (let i = 0; i < strings_length; i++) {
|
||||
let ptr = this.mem.loadPtr(strings_ptr + i*STRING_SIZE);
|
||||
let len = this.mem.loadPtr(strings_ptr + i*STRING_SIZE + 4);
|
||||
let ptr = this.mem.loadPtr(strings_ptr + i*stringSize);
|
||||
let len = this.mem.loadPtr(strings_ptr + i*stringSize + 4);
|
||||
let str = this.mem.loadString(ptr, len);
|
||||
source += str;
|
||||
}
|
||||
@@ -1151,10 +1168,11 @@ class WebGLInterface {
|
||||
},
|
||||
TransformFeedbackVaryings: (program, varyings_ptr, varyings_len, bufferMode) => {
|
||||
this.assertWebGL2();
|
||||
const stringSize = this.mem.intSize*2;
|
||||
let varyings = [];
|
||||
for (let i = 0; i < varyings_len; i++) {
|
||||
let ptr = this.mem.loadPtr(varyings_ptr + i*STRING_SIZE + 0*4);
|
||||
let len = this.mem.loadPtr(varyings_ptr + i*STRING_SIZE + 1*4);
|
||||
let ptr = this.mem.loadPtr(varyings_ptr + i*stringSize + 0*4);
|
||||
let len = this.mem.loadPtr(varyings_ptr + i*stringSize + 1*4);
|
||||
varyings.push(this.mem.loadString(ptr, len));
|
||||
}
|
||||
this.ctx.transformFeedbackVaryings(this.programs[program], varyings, bufferMode);
|
||||
@@ -1393,7 +1411,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
||||
},
|
||||
"odin_dom": {
|
||||
init_event_raw: (ep) => {
|
||||
const W = 4;
|
||||
const W = wasmMemoryInterface.intSize;
|
||||
let offset = ep;
|
||||
let off = (amount, alignment) => {
|
||||
if (alignment === undefined) {
|
||||
@@ -1407,6 +1425,13 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
||||
return x;
|
||||
};
|
||||
|
||||
let align = (alignment) => {
|
||||
const modulo = offset & (alignment-1);
|
||||
if (modulo != 0) {
|
||||
offset += alignment - modulo
|
||||
}
|
||||
};
|
||||
|
||||
let wmi = wasmMemoryInterface;
|
||||
|
||||
let e = event_temp_data.event;
|
||||
@@ -1427,10 +1452,12 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
||||
wmi.storeU32(off(4), 0);
|
||||
}
|
||||
|
||||
wmi.storeUint(off(W), event_temp_data.id_ptr);
|
||||
wmi.storeUint(off(W), event_temp_data.id_len);
|
||||
wmi.storeUint(off(W), 0); // padding
|
||||
align(W);
|
||||
|
||||
wmi.storeI32(off(W), event_temp_data.id_ptr);
|
||||
wmi.storeUint(off(W), event_temp_data.id_len);
|
||||
|
||||
align(8);
|
||||
wmi.storeF64(off(8), e.timeStamp*1e-3);
|
||||
|
||||
wmi.storeU8(off(1), e.eventPhase);
|
||||
@@ -1442,7 +1469,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
||||
wmi.storeU8(off(1), !!e.isComposing);
|
||||
wmi.storeU8(off(1), !!e.isTrusted);
|
||||
|
||||
let base = off(0, 8);
|
||||
align(8);
|
||||
if (e instanceof WheelEvent) {
|
||||
wmi.storeF64(off(8), e.deltaX);
|
||||
wmi.storeF64(off(8), e.deltaY);
|
||||
@@ -1689,8 +1716,15 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
||||
};
|
||||
};
|
||||
|
||||
async function runWasm(wasmPath, consoleElement, extraForeignImports) {
|
||||
let wasmMemoryInterface = new WasmMemoryInterface();
|
||||
/**
|
||||
* @param {string} wasmPath - Path to the WASM module to run
|
||||
* @param {?HTMLPreElement} consoleElement - Optional console/pre element to append output to, in addition to the console
|
||||
* @param {any} extraForeignImports - Imports, in addition to the default runtime to provide the module
|
||||
* @param {?int} intSize - Size (in bytes) of the integer type, should be 4 on `js_wasm32` and 8 on `js_wasm64p32`
|
||||
*/
|
||||
async function runWasm(wasmPath, consoleElement, extraForeignImports, intSize = 4) {
|
||||
const wasmMemoryInterface = new WasmMemoryInterface();
|
||||
wasmMemoryInterface.setIntSize(intSize);
|
||||
|
||||
let imports = odinSetupDefaultImports(wasmMemoryInterface, consoleElement);
|
||||
let exports = {};
|
||||
|
||||
Vendored
+1311
-1306
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user