From: Brendan Hansen Date: Mon, 13 Dec 2021 23:48:36 +0000 (-0600) Subject: stb_truetype integrated X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=6abb09e39a88be761acfd0d344413c8887f4c1c7;p=voxel-shooter.git stb_truetype integrated --- diff --git a/lib/stb_truetype.c b/lib/stb_truetype.c index 4781d4a..0fb24f4 100644 --- a/lib/stb_truetype.c +++ b/lib/stb_truetype.c @@ -37,6 +37,7 @@ static void __onyx_heap_free_wrapper(void *ptr, void* userdata) { #define STBTT_free __onyx_heap_free_wrapper #define STB_TRUETYPE_IMPLEMENTATION +#define STB_RECT_PACK_IMPLEMENTATION #include "stb_rect_pack.h" #include "stb_truetype.h" diff --git a/lib/stb_truetype.onyx b/lib/stb_truetype.onyx new file mode 100644 index 0000000..3e5aa73 --- /dev/null +++ b/lib/stb_truetype.onyx @@ -0,0 +1,26 @@ +package stb_truetype + +#library "stb_truetype" + +stbtt_pack_context :: struct #size 64 {} + +stbtt_packedchar :: struct #size 28 { + x0, y0, x1, y1: u16; + xoff, yoff, xadvance: f32; + xoff2, yoff2: f32; +} + +#foreign "stb_truetype" { + stbtt_PackBegin :: (ctx: ^stbtt_pack_context, pixels: ^u8, width, height, stride_in_bytes, padding: i32) -> i32 --- + stbtt_PackEnd :: (ctx: ^stbtt_pack_context) -> void --- + stbtt_PackFontRange :: (ctx: ^stbtt_pack_context, fontdata: ^u8, font_index: i32, font_size: f32, first_unicode_char_in_range: i32, num_chars_in_range: i32, chardata_for_range: ^stbtt_packedchar) -> i32 --- + stbtt_PackSetOversampling :: (ctx: ^stbtt_pack_context, h_oversample, v_oversample: i32) -> void --- +} + +#export "stbtt_heap_alloc" (size: i32) -> rawptr { + return calloc(size); +} + +#export "stbtt_heap_free" (ptr: rawptr) { + cfree(ptr); +} \ No newline at end of file diff --git a/run_tree/lib/stb_truetype.dll b/run_tree/lib/stb_truetype.dll new file mode 100644 index 0000000..04a6a9e Binary files /dev/null and b/run_tree/lib/stb_truetype.dll differ diff --git a/src/build.onyx b/src/build.onyx index e98d2f8..4e10af6 100644 --- a/src/build.onyx +++ b/src/build.onyx @@ -9,4 +9,6 @@ #library_path "./lib" #load "glfw3/module" -#load "opengles/module" \ No newline at end of file +#load "opengles/module" + +#load "./../lib/stb_truetype" \ No newline at end of file