updated to new version of Onyx
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 27 May 2022 16:17:58 +0000 (11:17 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 27 May 2022 16:17:58 +0000 (11:17 -0500)
src/gfx/font.onyx
src/gfx/texture.onyx

index 136f12f17cef812e1fdb160213520735bb48a564..1ece709364e1b38b11b9dbb97924f4e730b57a7d 100644 (file)
@@ -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;
 }
-
index da353b9325d73a5fef6b6399f1eba9f82855166c..5a205d49e9ca8bee308267828f653fa4a2bf7d58 100644 (file)
@@ -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
+}