diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/cube/ex_cube.c | 4 | ||||
-rw-r--r-- | examples/triangle/ex_triangle.c | 42 |
2 files changed, 25 insertions, 21 deletions
diff --git a/examples/cube/ex_cube.c b/examples/cube/ex_cube.c index 7b0ab48..a3d5a9f 100644 --- a/examples/cube/ex_cube.c +++ b/examples/cube/ex_cube.c @@ -70,8 +70,8 @@ int main() { str8 vert_path, frag_path; #ifdef CEL_REND_BACKEND_OPENGL - vert_path = str8lit("assets/shaders/blinn_phong.vert"); - frag_path = str8lit("assets/shaders/blinn_phong.frag"); + vert_path = str8lit("assets/shaders/cube.vert"); + frag_path = str8lit("assets/shaders/cube.frag"); #else vert_path = str8lit("build/linux/x86_64/debug/cube.vert.spv"); frag_path = str8lit("build/linux/x86_64/debug/cube.frag.spv"); diff --git a/examples/triangle/ex_triangle.c b/examples/triangle/ex_triangle.c index 0191c18..d9954e6 100644 --- a/examples/triangle/ex_triangle.c +++ b/examples/triangle/ex_triangle.c @@ -36,12 +36,12 @@ int main() { gpu_renderpass* renderpass = gpu_renderpass_create(&pass_description); str8 vert_path, frag_path; -#ifdef CEL_REND_BACKEND_OPENGL +#if defined(CEL_REND_BACKEND_OPENGL) vert_path = str8lit("assets/shaders/triangle.vert"); frag_path = str8lit("assets/shaders/triangle.frag"); -#else - vert_path = str8lit("build/linux/x86_64/debug/triangle.vert.spv"); - frag_path = str8lit("build/linux/x86_64/debug/triangle.frag.spv"); +#elif defined(CEL_REND_BACKEND_METAL) + vert_path = str8lit("build/gfx.metallib"); + frag_path = str8lit("build/gfx.metallib"); #endif str8_opt vertex_shader = str8_from_file(&scratch, vert_path); str8_opt fragment_shader = str8_from_file(&scratch, frag_path); @@ -57,7 +57,11 @@ int main() { .vs = { .debug_name = "Triangle Vertex Shader", .filepath = vert_path, .code = vertex_shader.contents, - .is_spirv = true }, +#ifdef CEL_REND_BACKEND_METAL + .is_combined_vert_frag = true, +#endif + .is_spirv = true, + }, .fs = { .debug_name = "Triangle Fragment Shader", .filepath = frag_path, .code = fragment_shader.contents, @@ -75,7 +79,7 @@ int main() { buffer_handle triangle_index_buf = gpu_buffer_create(sizeof(indices), CEL_BUFFER_INDEX, CEL_BUFFER_FLAG_GPU, indices); - // Main loop + // // Main loop while (!should_exit()) { input_update(&g_core.input); @@ -83,24 +87,24 @@ int main() { continue; } gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder(); - // Begin recording + // // Begin recording gpu_cmd_encoder_begin(*enc); gpu_cmd_encoder_begin_render(enc, renderpass); - encode_bind_pipeline(enc, PIPELINE_GRAPHICS, gfx_pipeline); - encode_set_default_settings(enc); + // encode_bind_pipeline(enc, PIPELINE_GRAPHICS, gfx_pipeline); + // encode_set_default_settings(enc); - // Record draw calls - encode_set_vertex_buffer(enc, triangle_vert_buf); - encode_set_index_buffer(enc, triangle_index_buf); - encode_draw_indexed(enc, 6); + // // Record draw calls + // encode_set_vertex_buffer(enc, triangle_vert_buf); + // encode_set_index_buffer(enc, triangle_index_buf); + // encode_draw_indexed(enc, 6); - // End recording - gpu_cmd_encoder_end_render(enc); + // // End recording + // gpu_cmd_encoder_end_render(enc); - gpu_cmd_buffer buf = gpu_cmd_encoder_finish( - enc); // Command buffer is no longer recording and is ready to submit - // Submit - gpu_queue_submit(&buf); + // gpu_cmd_buffer buf = gpu_cmd_encoder_finish(enc); // Command buffer is no longer recording + // and is ready to submit + // // Submit + // gpu_queue_submit(&buf); gpu_backend_end_frame(); } |