summaryrefslogtreecommitdiff
path: root/examples/cube
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-20 11:19:37 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-20 11:19:37 +1000
commit8d116bd23d9441e33cb3377e90c08169109b438a (patch)
tree01ab28847be90828a39bc946e1dba9f933c5f554 /examples/cube
parent74bb80d54f48a8576a796b15ccdf044cde435e79 (diff)
modify some comments in example
Diffstat (limited to 'examples/cube')
-rw-r--r--examples/cube/ex_cube.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/examples/cube/ex_cube.c b/examples/cube/ex_cube.c
index fc59e2d..68ce0d5 100644
--- a/examples/cube/ex_cube.c
+++ b/examples/cube/ex_cube.c
@@ -51,12 +51,12 @@ int main() {
core_bringup();
arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024);
- DEBUG("render capacity %d", g_core.default_scene.renderables->capacity);
-
vec3 camera_pos = vec3(2., 2., 2.);
vec3 camera_front = vec3_normalise(vec3_negate(camera_pos));
camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0));
+ // This is how to do it manually; run `static_3d_vertex_description()` to get this built-in vertex
+ // format
vertex_description vertex_input = { .use_full_vertex_size = true };
vertex_input.debug_label = "Standard Static 3D Vertex Format";
vertex_desc_add(&vertex_input, "inPosition", ATTR_F32x3);
@@ -102,7 +102,8 @@ int main() {
// Texture
texture_data tex_data = texture_data_load("assets/textures/texture.jpg", false);
texture_handle texture = texture_data_upload(tex_data, true);
- printf("Texture %d", texture.raw);
+
+ static f32 theta = 0.0;
// Main loop
while (!should_exit(&g_core)) {
@@ -118,12 +119,11 @@ int main() {
encode_bind_pipeline(enc, PIPELINE_GRAPHICS, gfx_pipeline);
encode_set_default_settings(enc);
- static f32 x = 0.0;
- x += 0.01;
- quat rotation = quat_from_axis_angle(VEC3_Y, x, true);
- mat4 translation = mat4_translation(vec3(-0.5, -0.5, -0.5));
- mat4 model = mat4_rotation(rotation);
- model = mat4_mult(translation, model);
+ theta += 0.01;
+ transform transform = { .position = vec3(-0.5, -0.5, -0.5),
+ .rotation = quat_from_axis_angle(VEC3_Y, theta, true),
+ .scale = 1.0 };
+ 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);
@@ -133,12 +133,7 @@ int main() {
encode_bind_shader_data(enc, 0, &mvp_uniforms_data);
// Record draw calls
- // -- NEW
draw_mesh(&cube, &model);
- // -- OLD
- /* encode_set_vertex_buffer(enc, triangle_vert_buf); */
- /* encode_set_index_buffer(enc, triangle_index_buf); */
- /* gpu_temp_draw(6); */
// End recording
gpu_cmd_encoder_end_render(enc);
@@ -147,9 +142,6 @@ int main() {
gpu_queue_submit(&buf);
// Submit
gpu_backend_end_frame();
-
- // render_frame_end(&g_core.renderer);
- // glfwSwapBuffers(core->renderer.window);
}
renderer_shutdown(&g_core.renderer);