diff options
author | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-02-25 12:50:39 +1100 |
---|---|---|
committer | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-02-25 12:50:39 +1100 |
commit | 80a734de03eaf3d534f95010653c47bf54389f48 (patch) | |
tree | 2b75a7516116e5e66ead39b48bd1ceb6b67a4af3 /examples/main_loop/ex_main_loop.c | |
parent | 4b9ab2ec5acf2ecf2e96c38733a835b964664171 (diff) |
new string function signatures just dropped
Diffstat (limited to 'examples/main_loop/ex_main_loop.c')
-rw-r--r-- | examples/main_loop/ex_main_loop.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/examples/main_loop/ex_main_loop.c b/examples/main_loop/ex_main_loop.c index 0ea9ded..de0caa6 100644 --- a/examples/main_loop/ex_main_loop.c +++ b/examples/main_loop/ex_main_loop.c @@ -1,22 +1,45 @@ #include <GLFW/glfw3.h> #include "core.h" +#include "file.h" #include "render.h" +#include "str.h" int main() { core* core = core_bringup(); - // Main loop - while (!glfwWindowShouldClose(core->renderer.window)) { - input_update(&core->input); - threadpool_process_results(&core->threadpool, 1); + size_t arena_size = 1024; + arena scratch = arena_create(malloc(arena_size), arena_size); + arena* a = &scratch; + + str8 hello = str8lit("Hello World"); + + // this works but we should be careful because str8 is not *guaranteed* to point to + // a null-terminated string + printf("String before: '%s' (null-terminated: %s) \n ", hello.buf, + str8_is_null_term(hello) ? "true" : "false"); - render_frame_begin(&core->renderer); + char* c = str8_to_cstr(&scratch, hello); - // insert work here + printf("String after: %s\n", c); - render_frame_end(&core->renderer); + str8_opt test_file = str8_from_file(&scratch, str8lit("assets/shaders/ui_rect.vert")); + if (test_file.has_value) { + printf("Contents: %.*s \n", (int)test_file.contents.len, test_file.contents.buf); + printf("Null-terminated: %s\n", str8_is_null_term(test_file.contents) ? "true" : "false"); } + // Main loop + // while (!glfwWindowShouldClose(core->renderer.window)) { + // input_update(&core->input); + // threadpool_process_results(&core->threadpool, 1); + // + // render_frame_begin(&core->renderer); + // + // // insert work here + // + // render_frame_end(&core->renderer); + // } + return 0; -}
\ No newline at end of file +} |