use core
-use core.intrinsics.onyx {__zero_value}
use stb_truetype
use opengles
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);
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;
if font_registry->has(fd) {
return font_registry[fd];
}
-
+
font := font_make(fd);
font_registry[fd] = font;
return font;
}
-
use core
-use core.intrinsics.onyx { __zero_value as Zero }
use opengles
use stb_image
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);
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);
}
map.clear(^texture_cache);
-}
\ No newline at end of file
+}