mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-05 14:42:42 -07:00
Add assignable allocator support to stb_truetype
This commit is contained in:
BIN
thirdparty/stb/lib/stb_truetype.lib
vendored
BIN
thirdparty/stb/lib/stb_truetype.lib
vendored
Binary file not shown.
10824
thirdparty/stb/src/gb/gb.h
vendored
Normal file
10824
thirdparty/stb/src/gb/gb.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
thirdparty/stb/src/stb_image.c
vendored
Normal file
2
thirdparty/stb/src/stb_image.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
7897
thirdparty/stb/src/stb_image.h
vendored
Normal file
7897
thirdparty/stb/src/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
thirdparty/stb/src/stb_truetype.h
vendored
37
thirdparty/stb/src/stb_truetype.h
vendored
@@ -412,6 +412,43 @@ int main(int arg, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma region ODIN: CUSTOM ALLOCATOR
|
||||
|
||||
#ifdef STB_TRUETYPE_IMPLEMENTATION
|
||||
#define GB_IMPLEMENTATION
|
||||
#endif
|
||||
#include "gb/gb.h"
|
||||
|
||||
#ifdef STBTT_STATIC
|
||||
#define STBTT_DEF static
|
||||
#else
|
||||
#define STBTT_DEF extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
STBTT_DEF void stbtt_SetAllocator( gbAllocator allocator );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef STBTT_malloc
|
||||
#define STBTT_malloc(x,u) ((void)(u), gb_alloc(stbtt__allocator, x))
|
||||
#define STBTT_free(x,u) ((void)(u), gb_free(stbtt__allocator, x))
|
||||
#endif
|
||||
|
||||
#ifdef STB_TRUETYPE_IMPLEMENTATION
|
||||
gb_global gbAllocator stbtt__allocator = { gb_heap_allocator_proc, NULL };
|
||||
|
||||
STBTT_DEF void stbtt_SetAllocator( gbAllocator allocator ) {
|
||||
stbtt__allocator = allocator;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma endregion ODIN: CUSTOM ALLOCATOR
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
31
thirdparty/stb/truetype/stb_truetype.odin
vendored
31
thirdparty/stb/truetype/stb_truetype.odin
vendored
@@ -36,6 +36,37 @@ when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
||||
#assert(size_of(c.int) == size_of(rune))
|
||||
#assert(size_of(c.int) == size_of(b32))
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CUSTOM: ODIN COMPATIBLE ALLOCATOR
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
gbAllocationType :: enum(i32) {
|
||||
Alloc,
|
||||
Free,
|
||||
FreeAll,
|
||||
Resize,
|
||||
}
|
||||
|
||||
gbAllocatorProc :: #type proc(allocator_data: rawptr, type: gbAllocationType,
|
||||
size: c.ssize_t, alignment: c.ssize_t,
|
||||
old_memory: rawptr, old_size: c.ssize_t,
|
||||
flags : c.ulonglong
|
||||
) -> rawptr
|
||||
|
||||
gbAllocator :: struct {
|
||||
procedure: gbAllocatorProc,
|
||||
data: rawptr,
|
||||
}
|
||||
|
||||
@(default_calling_convention="c", link_prefix="stbtt_")
|
||||
foreign stbtt {
|
||||
SetAllocator :: proc(allocator : gbAllocator) ---
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// END CUSTOM: ODIN COMPATIBLE ALLOCATOR
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTURE BAKING API
|
||||
|
Reference in New Issue
Block a user