diff options
author | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-05-11 00:22:13 +1000 |
---|---|---|
committer | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-05-11 00:22:13 +1000 |
commit | eedd332680dbdd367197616658903f00252f5a9c (patch) | |
tree | b50b7fe4c014abd8fee65a2cb1567d8df9a38e7e /examples/triangle/ex_triangle.c | |
parent | 3bd21c92678c62e61c10ba730e8c839edc5e967a (diff) |
upload data using staging buffer. use vertex buffer data
Diffstat (limited to 'examples/triangle/ex_triangle.c')
-rw-r--r-- | examples/triangle/ex_triangle.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/examples/triangle/ex_triangle.c b/examples/triangle/ex_triangle.c index 7b8a1d0..c4f90f2 100644 --- a/examples/triangle/ex_triangle.c +++ b/examples/triangle/ex_triangle.c @@ -1,6 +1,7 @@ #include <glfw3.h> #include "backend_vulkan.h" +#include "buf.h" #include "camera.h" #include "core.h" #include "file.h" @@ -8,12 +9,20 @@ #include "maths.h" #include "mem.h" #include "ral.h" +#include "ral_types.h" #include "render.h" // Example setting up a renderer extern core g_core; +const custom_vertex vertices[] = { + (custom_vertex){ .pos = vec2(-0.5, 0.5), .color = vec3(0.0, 0.0, 1.0) }, + (custom_vertex){ .pos = vec2(0.5, 0.5), .color = vec3(0.0, 1.0, 0.0) }, + (custom_vertex){ .pos = vec2(0.0, -0.5), .color = vec3(1.0, 0.0, 0.0) }, +}; +_Static_assert(sizeof(vertices) == (5 * 3 * sizeof(float)), ""); + int main() { core_bringup(); arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024); @@ -47,12 +56,19 @@ int main() { }; gpu_pipeline* gfx_pipeline = gpu_graphics_pipeline_create(pipeline_description); + buffer_handle triangle_vert_buf = gpu_buffer_create( + 3 * sizeof(custom_vertex), CEL_BUFFER_VERTEX, CEL_BUFFER_FLAG_GPU, + vertices); // gpu_buffer_create(3 * sizeof(custom_vertex), CEL_BUFFER_VERTEX); + /* buffer_upload_bytes(triangle_vert_buf, (bytebuffer){ .buf = vertices, .size = sizeof(vertices) + * }, */ + /* 0, sizeof(vertices)); */ + // Main loop while (!should_exit(&g_core)) { glfwPollEvents(); input_update(&g_core.input); - render_frame_begin(&g_core.renderer); + // render_frame_begin(&g_core.renderer); static f64 x = 0.0; x += 0.01; @@ -68,7 +84,8 @@ int main() { encode_set_default_settings(enc); // Record draw calls - gpu_temp_draw(); + encode_set_vertex_buffer(enc, triangle_vert_buf); + gpu_temp_draw(3); // End recording gpu_cmd_encoder_end_render(enc); @@ -78,7 +95,7 @@ int main() { // Submit gpu_backend_end_frame(); - render_frame_end(&g_core.renderer); + // render_frame_end(&g_core.renderer); // glfwSwapBuffers(core->renderer.window); } |