diff options
Diffstat (limited to 'examples/cube/ex_cube.c')
-rw-r--r-- | examples/cube/ex_cube.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/examples/cube/ex_cube.c b/examples/cube/ex_cube.c index 68ce0d5..e85b5c1 100644 --- a/examples/cube/ex_cube.c +++ b/examples/cube/ex_cube.c @@ -62,14 +62,21 @@ int main() { vertex_desc_add(&vertex_input, "inPosition", ATTR_F32x3); vertex_desc_add(&vertex_input, "inNormal", ATTR_F32x3); vertex_desc_add(&vertex_input, "inTexCoords", ATTR_F32x2); + vertex_input.use_full_vertex_size = true; shader_data mvp_uniforms_data = { .data = NULL, .shader_data_get_layout = &mvp_uniforms_layout }; gpu_renderpass_desc pass_description = {}; gpu_renderpass* renderpass = gpu_renderpass_create(&pass_description); - str8 vert_path = str8lit("build/linux/x86_64/debug/cube.vert.spv"); - str8 frag_path = str8lit("build/linux/x86_64/debug/cube.frag.spv"); + str8 vert_path, frag_path; +#ifdef CEL_REND_BACKEND_OPENGL + 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"); +#endif str8_opt vertex_shader = str8_from_file(&scratch, vert_path); str8_opt fragment_shader = str8_from_file(&scratch, frag_path); if (!vertex_shader.has_value || !fragment_shader.has_value) { @@ -123,14 +130,23 @@ int main() { transform transform = { .position = vec3(-0.5, -0.5, -0.5), .rotation = quat_from_axis_angle(VEC3_Y, theta, true), .scale = 1.0 }; + /* INFO("Swapchain dimensions x %d y %d", g_core.renderer.swapchain.dimensions.x, + * g_core.renderer.swapchain.dimensions.y); */ + mat4 model = transform_to_mat(&transform); mat4 view, proj; - camera_view_projection(&cam, g_core.renderer.swapchain.extent.width, - g_core.renderer.swapchain.extent.height, &view, &proj); + camera_view_projection(&cam, 1000, 1000, + /* g_core.renderer.swapchain.dimensions.x, */ + /* g_core.renderer.swapchain.dimensions.y, */ + &view, &proj); mvp_uniforms mvp_data = { .model = model, .view = view, .projection = proj }; my_shader_bind_group shader_bind_data = { .mvp = mvp_data, .tex = texture }; mvp_uniforms_data.data = &shader_bind_data; - encode_bind_shader_data(enc, 0, &mvp_uniforms_data); + /* encode_bind_shader_data(enc, 0, &mvp_uniforms_data); */ + + uniform_mat4f(enc->pipeline->shader_id, "model", &model); + uniform_mat4f(enc->pipeline->shader_id, "view", &view); + uniform_mat4f(enc->pipeline->shader_id, "projection", &proj); // Record draw calls draw_mesh(&cube, &model); |