Manually adding thirdparty libs

This commit is contained in:
2025-04-14 14:49:36 -04:00
parent 1bd2dc2333
commit 77f1466ae3
70 changed files with 60610 additions and 4 deletions

38
thirdparty/sokol/helpers/allocator.odin vendored Normal file
View File

@@ -0,0 +1,38 @@
package sokol_helpers
// Use native odin allocators in sokol allocator interface
import sapp "../app"
import sg "../gfx"
import "base:runtime"
import "core:c"
Allocator :: struct {
alloc_fn: proc "c" (size: c.size_t, user_data: rawptr) -> rawptr,
free_fn: proc "c" (ptr: rawptr, user_data: rawptr),
user_data: rawptr,
}
// context_ptr: a pointer to a context which persists during the lifetime of the program.
// Note: you can transmute() this into a logger for any specific sokol library.
allocator :: proc(context_ptr: ^runtime.Context) -> Allocator {
return {
alloc_fn = allocator_alloc_proc,
free_fn = allocator_free_proc,
user_data = cast(rawptr)context_ptr,
}
}
allocator_alloc_proc :: proc "c" (size: c.size_t, user_data: rawptr) -> rawptr {
context = (cast(^runtime.Context)user_data)^
bytes, err := runtime.mem_alloc(size = int(size))
if err != nil {
return nil
}
return raw_data(bytes)
}
allocator_free_proc :: proc "c" (ptr: rawptr, user_data: rawptr) {
context = (cast(^runtime.Context)user_data)^
runtime.mem_free(ptr)
}