From da545aba47fc21bd48cf6ff182bd0b77f963bde8 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 27 May 2022 11:17:58 -0500 Subject: [PATCH] updated to new version of Onyx --- src/gfx/font.onyx | 8 +++----- src/gfx/texture.onyx | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gfx/font.onyx b/src/gfx/font.onyx index 136f12f..1ece709 100644 --- a/src/gfx/font.onyx +++ b/src/gfx/font.onyx @@ -1,6 +1,5 @@ use core -use core.intrinsics.onyx {__zero_value} use stb_truetype use opengles @@ -78,7 +77,7 @@ font_make :: (fd: FontDescriptor) -> Font { ttf_file := os.get_contents(fd.path); if ttf_file.count == 0 { println("Bad font"); - return __zero_value(Font); + return .{}; } defer cfree(ttf_file.data); @@ -87,7 +86,7 @@ font_make :: (fd: FontDescriptor) -> Font { ctx: stbtt_pack_context; stbtt_PackBegin(^ctx, pixels, texture_size, texture_size, 0, 1); - stbtt_PackFontRange(^ctx, ttf_file.data, 0, ~~fd.size, #char " ", 96, char_data.data); + stbtt_PackFontRange(^ctx, ttf_file.data, 0, ~~fd.size, #char " ", 96, char_data.data); stbtt_PackEnd(^ctx); texture: GLint; @@ -260,9 +259,8 @@ font_lookup :: (fd := FontDescriptor.{ "assets/calibri.ttf", 12 }) -> Font { if font_registry->has(fd) { return font_registry[fd]; } - + font := font_make(fd); font_registry[fd] = font; return font; } - diff --git a/src/gfx/texture.onyx b/src/gfx/texture.onyx index da353b9..5a205d4 100644 --- a/src/gfx/texture.onyx +++ b/src/gfx/texture.onyx @@ -1,6 +1,5 @@ use core -use core.intrinsics.onyx { __zero_value as Zero } use opengles use stb_image @@ -17,7 +16,7 @@ texture_lookup :: #match {} if texture_cache->has(filename) { return texture_cache[filename], true; } - + buffer: [512] u8; memory.copy(~~ buffer, filename.data, math.min(filename.count, 511)); return texture_lookup(cast(cstr) buffer); @@ -34,7 +33,7 @@ texture_lookup :: #match {} pixels := stbi_load(path, ^tex.width, ^tex.height, ^tex.channels, 4); if pixels == null { debug_log(.Warning, "Failed to load texture: {}", filename); - return Zero(Texture), false; + return .{}, false; } defer stbi_image_free(pixels); @@ -85,4 +84,4 @@ texture_cache_clear :: () { } map.clear(^texture_cache); -} \ No newline at end of file +} -- 2.25.1