diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2025-04-16 12:22:44 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2025-04-16 12:22:44 +0200 |
commit | 95933facfbc45f667f051440ceb374f16b051fcc (patch) | |
tree | 5ec8be4a73f000cf25035c8374eaa95a7ed6eb3b | |
parent | 24e30558d8b30d399a69dd99a510fd43ca075cfe (diff) | |
download | reduced_system_layer-95933facfbc45f667f051440ceb374f16b051fcc.zip |
Add test letter A
-rwxr-xr-x | graphics.c | 45 | ||||
-rwxr-xr-x | reduced_system_layer.c | 7 |
2 files changed, 50 insertions, 2 deletions
@@ -2252,6 +2252,49 @@ TEST("colors") { REQUIRE_EQ((purple.z + 2e-7) * 100, 100); } +TEST("text letter A") { + i64 w = 10; + i64 h = 10; + + vec4_f32 pixels[100] = {0}; + + draw_text_area_to_buffer( + (Pixel_Buffer) { + .width = 10, + .height = 10, + .stride = 10, + .pixels = pixels, + }, + 0, + (vec4_f32) { 1.0f, 1.0f, 1.0f, 1.0f, }, + (Box) { .x = 0, .y = 0, .width = 10, .height = 10, }, + (vec2) { .x = 10.0, .y = 10.0, }, + 1, + (c32[1]) { 'A', } + ); + + b8 expect_bits[100] = { + 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + + for (i64 i = 0; i < w * h; ++i) { + b8 bit = pixels[i].x > 0.5; + if (expect_bits[i] != bit) { + REQUIRE(0); + break; + } + } +} + static Pixel_Buffer _test_pixels = { .width = 1280, .height = 720, @@ -2260,7 +2303,7 @@ static Pixel_Buffer _test_pixels = { }; #ifndef EVERY_TEST_SUITE -void update_and_render_frame(void) {} +void update_and_render_frame(void) { } i32 main(i32 argc, c8 **argv) { return run_tests(argc, argv); diff --git a/reduced_system_layer.c b/reduced_system_layer.c index cd0a4a3..f34c03d 100755 --- a/reduced_system_layer.c +++ b/reduced_system_layer.c @@ -1498,6 +1498,7 @@ typedef struct { i64 begin_nsec; } Profiler_Slot_; +b8 _profiler_ready = 0; i64 _profiler_num_slots = 0; Profiler_Slot_ *_profiler_slots = NULL; @@ -1512,10 +1513,12 @@ void PROFILER_init(u32 slot, c8 *name) { mem_set_(_profiler_slots + slot, 0, sizeof *_profiler_slots); _profiler_slots[slot].name = name; + + _profiler_ready = 1; } void PROFILER_begin(u32 slot) { - if ((i64) (u64) slot >= _profiler_num_slots && slot == PROFILE_MEMORY) + if (!_profiler_ready) return; if ((i64) (u64) slot >= _profiler_num_slots) { @@ -1558,6 +1561,8 @@ static void normalize_time_(i64 *sec, i64 *nsec) { } void PROFILER_end(u32 slot) { + if (!_profiler_ready) + return; if ((i64) (u64) slot >= _profiler_num_slots) return; |